JSFiddle - React, Tailwind, and code Playground

by frogggeee McFrogggeee

JavaScript

#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
 ...