/************************************************************************* ** ** ** Main: Simple bumper car ** ** ** *************************************************************************/ #include "legocore.h" #define LEFT_MOTOR OUT_CHAN0 #define RIGHT_MOTOR OUT_CHAN1 #define LEFT_BUMPER IN_CHAN1 #define RIGHT_BUMPER IN_CHAN0 WaitSecond(unsigned char Num) { unsigned char i; for(i=0;i100){ // 5 seconds Speed = 255; SetOutputValue(LEFT_MOTOR|RIGHT_MOTOR,Speed); } if(HitFree>200){ // 10 seconds SetFloat(LEFT_MOTOR|RIGHT_MOTOR); WaitSecond(3); SetReverse(RIGHT_MOTOR); SetForward(LEFT_MOTOR); // Turn Right Speed = 10; for(i=0;i<50;i++){ SetOutputValue(LEFT_MOTOR|RIGHT_MOTOR,Speed); Waitms(80); if(Speed<230) Speed += 10; else Speed = 255; } SetFloat(LEFT_MOTOR|RIGHT_MOTOR); Waitms(1500); SetForward(RIGHT_MOTOR); Speed = 128; SetOutputValue(LEFT_MOTOR|RIGHT_MOTOR,Speed); HitFree = 0; } } }