abbiati012
New Member
I am doing my robot programming, it supposes to turn left, stop, and turn right, but now it just make turns, I can't figure out, anyone can take look at my programming, thank u for reading , I really appreciate.....
int RIGHT_MOTOR= 0;
int LEFT_MOTOR = 2;
int LEFT_BUMPER=7;
int RIGHT_BUMPER=9;
#define TURE 1
#define FALSE 0
#define FORWARD 1
#define REVERSE 2
#define TURN_LEFT 3
#define TURN_RIGHT 4
#define STOP 5
persistent int ix;
void main()
{
while(1)
{
printf("Press start\n");
if (start_button())
{
while (!stop_button())
{
motor_routine(FORWARD);
if (digital(7))
{
motor_routine(STOP);
sleep(0.25);
motor_routine(REVERSE);
sleep(0.25);
motor_routine(TURN_RIGHT);
}
if (digital(9))
{
motor_routine(STOP);
sleep(.2);
motor_routine (REVERSE);
sleep(0.2);
motor_routine(TURN_LEFT);
sleep(.2);
}
}
}
}
}
void motor_routine( int motor_cmd)
{
if( motor_cmd==FORWARD)
{
fd(RIGHT_MOTOR);
fd(LEFT_MOTOR);
}
if( motor_cmd==REVERSE)
{
bk(RIGHT_MOTOR);
bk(LEFT_MOTOR);
}
if( motor_cmd==TURN_RIGHT)
{
ao();
motor(RIGHT_MOTOR,45);
}
if( motor_cmd==TURN_LEFT)
{
ao();
motor(LEFT_MOTOR,45);
}
if (motor_cmd==STOP)
{
ao();
}
}
int RIGHT_MOTOR= 0;
int LEFT_MOTOR = 2;
int LEFT_BUMPER=7;
int RIGHT_BUMPER=9;
#define TURE 1
#define FALSE 0
#define FORWARD 1
#define REVERSE 2
#define TURN_LEFT 3
#define TURN_RIGHT 4
#define STOP 5
persistent int ix;
void main()
{
while(1)
{
printf("Press start\n");
if (start_button())
{
while (!stop_button())
{
motor_routine(FORWARD);
if (digital(7))
{
motor_routine(STOP);
sleep(0.25);
motor_routine(REVERSE);
sleep(0.25);
motor_routine(TURN_RIGHT);
}
if (digital(9))
{
motor_routine(STOP);
sleep(.2);
motor_routine (REVERSE);
sleep(0.2);
motor_routine(TURN_LEFT);
sleep(.2);
}
}
}
}
}
void motor_routine( int motor_cmd)
{
if( motor_cmd==FORWARD)
{
fd(RIGHT_MOTOR);
fd(LEFT_MOTOR);
}
if( motor_cmd==REVERSE)
{
bk(RIGHT_MOTOR);
bk(LEFT_MOTOR);
}
if( motor_cmd==TURN_RIGHT)
{
ao();
motor(RIGHT_MOTOR,45);
}
if( motor_cmd==TURN_LEFT)
{
ao();
motor(LEFT_MOTOR,45);
}
if (motor_cmd==STOP)
{
ao();
}
}