Recently, our teams are running into some obstacles with programming. Unfortunately, I’m not much of a programmer. Can you guys please review this code? We wont have access to a compiler for a while.
This is what we’re trying to do
-Get the lift to raise at the start of the match
-trigger a sensor with a bumper switch and Bump a large ball and return to the tile
-Trigger a sensor with a bumper switch and Bump a second large ball, return to the tile while opening the funnels and lower lift(the part im worried about)
-Drive forward, enclose the funnels on the bump buckies
-close funnels to set up driver control
If you can check part of the code, we should be able to figure out the rest
//raise lift at the start of the match. 3 motors are on lift
motor[LeftLift] = -127;
motor[RightLift1] = 127;
motor[RightLift2] = 127;
wait1Msec(1500)
While 1==1
{
motor[LeftLift] = -16; //The robot maintains lift position for the duration of autonomous
motor[RightLift1] = 16;
motor[RightLift2] = 16;
if (SensorType[Bump1] == 1) //If 1st bumper switch is pushed by driver, robot goes forward, pushes large ball, and returns
{
motor[FrontRight] = -127;
motor[FrontLeft] = 127;
motor[BackRight] = -127;
motor[backLeft] = 127;
wait1Msec(1500)
//slow down
motor[FrontRight] = -10;
motor[FrontLeft] = 10;
motor[BackRight] = -10;
motor[backLeft] = 10;
wait1Msec(500)
//return to tile
motor[FrontRight] = 127;
motor[FrontLeft] = -127;
motor[BackRight] = 127;
motor[backLeft] = -127;
wait1Msec(1250)
}
if (SensorType[Bump2] == 1) //If 2nd bumper switch is pushed by driver, robot goes forward, pushes large ball, returns, opens funnels + lowers lift
{
motor[FrontRight] = -127;
motor[FrontLeft] = 127;
motor[BackRight] = -127;
motor[backLeft] = 127;
wait1Msec(2000)
//slow down
motor[FrontRight] = -10;
motor[FrontLeft] = 10;
motor[BackRight] = -10;
motor[backLeft] = 10;
wait1Msec(500)
//return to tile + open funnels
motor[Funnel] = -127;
motor[FrontRight] = 127;
motor[FrontLeft] = -127;
motor[BackRight] = 127;
motor[backLeft] = -127;
wait1Msec(800)
//Continue returning to tile + stop opening Funnels
motor[FrontRight] = 127;
motor[FrontLeft] = -127;
motor[BackRight] = 127;
motor[backLeft]` = -127;
motor[LeftLift] = 30;
motor[RightLift1] = -30;
motor[RightLift2] = -30;
wait1Msec(1100)
}
if (SensorType[Bump3] == 1) //If 3rd bumper switch is pushed by driver, robot goes forward, gathers buckies, and retracts funnels
{
motor[FrontRight] = -127;
motor[FrontLeft] = 127;
motor[BackRight] = -127;
motor[backLeft] = 127;
wait1Msec(2000)
//open funnels to push in buckies
motor[Funnel] = -127;
wait1Msec(500)
//close funnels to set up driver control
motor[Funnel] = 127;
wait1Msec(1250)
}
}
this is something extra i’m trying to do, but i’m no sure if my logic is sound. I’m trying to make the next task start by declaring a variable. Then, by pressing the button an additional time, the next task will be executed.
int X = 0
if (SensorType[BumpX] == 1)
{
X = X+1
}
if(X=1)
{
first task
}
if(X=2)
{
Second task
}
if(X=3)
{
Third task
}