- Today we assembled and programmed the squarebot to drive through a maze. We used commands to tell the robot where to go during the maze. This code is not autonomous because it is not dependent on any sensors.
- Here is the code for our sqaure bot
/*************************************************************************
VEX - Point Turns
Description: This program instructs your robot turn right for .75 seconds
and then turn left for .75 seconds. There is a two second pause at the
beginning of the program.
Configuration: This program is written to work with the Squarebot model.
Right Motor - port2
Left Motor - port3
Additional Notes:
- The "bMotorReflected[port2] = 1;" is needed with the Squarebot model,
but may not be needed for all robot configurations.
- Point Turns, or turns in place, are achieved by having the motors spin
in opposite directions.
*************************************************************************/
void stop(int x);
task main()
{
wait1Msec(3000); //Robot waits for 2000 milliseconds before executing program
bMotorReflected[port2] = 1; //Reflects the direction of the motor on port2
motor[port2] = 70; //Motor forward 1
motor[port3] = 70; //Motor on port3 is run at full (127) power forward
wait1Msec(3000);
stop(500);
//Turn LEFT
motor[port2] = 78; //Motor on port2 is run at full (-127) power reverse 68
motor[port3] = -83; //Motor on port3 is run at full (127) power forward
wait1Msec(400);//Robot runs previous code for 750 milliseconds before moving on
stop(500);
motor[port2] = 95; //FORWARD 2
motor[port3] = 95; //Motor on port3 is run at full (127) power forward
wait1Msec(1000);
stop(500);
motor[port2] = 130; //Turn 2nd LEFT
motor[port3] = -100; //Motor on port3 is run at full (127) power forward
wait1Msec(300);
stop(500);
motor[port2] = 85; //Forward 3
motor[port3] = 85; //Motor on port3 is run at full (127) power forward
wait1Msec(1700);
stop(500);
motor[port2] = -70; //Turn RIGHT
motor[port3] = 70; //Motor on port3 is run at full (127) power forward 68-70
wait1Msec(500);
stop(500);
motor[port2] = 60; //Foward 4
motor[port3] = 60; //Motor on port3 is run at full (127) power forward
wait1Msec(1000);
stop(500);
motor[port2] = -88; //Turn RIGHT
motor[port3] = 88; //Motor on port3 is run at full (127) power forward
wait1Msec(400);
stop(500);
motor[port2] = 80; //Final Forwa
motor[port3] = 80; //Motor on port3 is run at full (127) power forward
wait1Msec(2000);
} //Program ends, and the robot stops
void stop(int x)
{
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(x);
}
- In addition here is a video that shows our square bot in action
No comments:
Post a Comment