#pragma config(Sensor, in1, ballSensor, sensorLineFollower)
#pragma config(Sensor, dgtl1, button, sensorTouch)
#pragma config(Sensor, dgtl2, green1, sensorLEDtoVCC)
#pragma config(Sensor, dgtl3, red1, sensorLEDtoVCC)
#pragma config(Sensor, dgtl4, green2, sensorLEDtoVCC)
#pragma config(Sensor, dgtl5, red2, sensorLEDtoVCC)
#pragma config(Motor, port1, bottomMotor, tmotorVex269_HBridge, openLoop)
#pragma config(Motor, port10, topMotor, tmotorVex269_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*pseudocode:
*/
task main()
{
// declare variables
bool lights = false; // lights
int delay = 49000; // delay
int through = false; // variable to tell if the marble has gone through
while (SensorValue(button) == 0) {} // while the button is not pressed
clearTimer(T1); // lights timer
clearTimer(T2); // ball timer
clearTimer(T3); // timer to check if the ball went through
for (int i = 0; i < 21; i++) { // start of loop
clearTimer(T2);
while (time1[T2] < delay) {
if (time1[T1] == 500){ // if the timer equals 500 milliseconds
clearTimer(T1); // clear the lights timer
if (lights == false) { // if the lights variable is false
lights = true; // set the lights variable to true
SensorValue(red1) = 0; // change the color of the lights
SensorValue(red2) = 0;
SensorValue(green1) = 1;
SensorValue(green2) = 1;
} else if (lights == true) { // if the lights variable is true
lights = false; // set the lights variable to false
SensorValue(red1) = 1; // change the color of the lights
SensorValue(red2) = 1;
SensorValue(green1) = 0;
SensorValue(green2) = 0;
}
}
} // end of while the delay is smaller than the timer
if (time1[T2] > delay) { // if the timer equals the delay we want
clearTimer(T3); // clear timer3
through = false; // set the through variable to false
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.