Professional Documents
Culture Documents
Code
Code
Code
//how
task main()
{
//Program begins, insert code within curly braces
SensorValue(quad) = 0;
int x = 1;
while (x == 1)
//Starts program when switch is pressed
{
if (SensorValue(limitSwitch) == 1)
{
x = 2;
}
}
while(1 == 1)
{
startMotor(ttMotor, -20);
//turn turning
startMotor(3, 45);
//start taMotor to tilt marble into bin
wait(1);
stopMotor(3);
startMotor(ttMotor, 20);
untilEncoderCounts(0, 5);
stopMotor(ttMotor);
}
else if (SensorValue(lightSensor) <= upperAlThreshold &&
SensorValue(lightSensor) >= lowerAlThreshold)
//if light sensor detects aluminum marble
{
wait(1);
//wait for 1 sec.
startMotor(ttMotor, -20);
//turn turning
table on slow speed
untilEncoderCounts(turnToAl, 5);
stopMotor(ttMotor);
startMotor(3, 45);
//start taMotor to tilt marble into bin
wait(1);
stopMotor(3);
startMotor(ttMotor, 20);
untilEncoderCounts(0, 5);
stopMotor(ttMotor);
}
else;
turnFlashlightOff(flashlight);
}
}