

(People who think they can multitask by texting while driving are dangerously wrong.)Ī much simpler approach works if the robot doesn't need to run the bumper/motor control loop while flashing the LEDs, that is, if it doesn't mind being unresponsive to the bumpers while flashing the LEDs for 1 second. There are alternatives for the tracking variables, such as 3 separate variables for whether it's currently flashing, which of the 7 flash cycles it's currently doing, whether it's in the ON or OFF phase of that cycle, and the clock reading.Īpproach #2 is trickier because doing two things at once is tricky. The program, ROBOTC, totally ignores the comments as long as the.

The selection will enable features and commands specifically for the selected system. Allows you to toggle ROBOTC’s programming modes. The simplest tracking variable would be a counter from 0 (initial state) to 14 (doing the last LED "OFF" phase) and the value of the system clock from the last change, to let you detect when the clock is 71 msec later than that. Display of the latest ROBOTC news, version of ROBOTC, and ROBOTC Resources. turn off and set the tracking variables back to the initial state after 14 of those steps. The steps are: turn on the LEDs when it was in the initial state and the light sensor is above-threshold, turn off the LEDs when it's 1/14 of a second later, turn on the LEDs when it's 1/14 of a second later.
#Vex robotc programming update#
Each cycle around the main loop, use if statements to check those variables, do the next step in the flash-LED cycle if it's time, and update those variables. Use variables to track the sequencing through the flash-LED loop.Or, you could use wait1Msec(71) to wait 71 msec, which is about 1/14 second.

I wrote that as 1.0/14.0 rather than 1/14 because many programming languages compute 1/14 in integer math, yielding 0, while 1.0/14.0 uses floating point math. That way, 7 cycles around the loop will take 7 * (1/14 + 1/14) = 1.0 seconds. While (SensorValue(bumpSwitch) = 0 & SensorValue(bumpSwitch2) = 0). #pragma config(Motor, port10, rightMotor, tmotorVex269, openLoop) #pragma config(Motor, port1, leftMotor, tmotorVex269, openLoop) #pragma config(Sensor, dgtl11, ledRed, sensorLEDtoVCC) #pragma config(Sensor, dgtl10, ledGreen, sensorLEDtoVCC) #pragma config(Sensor, dgtl4, bumpSwitch2, sensorTouch) #pragma config(Sensor, dgtl3, bumpSwitch, sensorTouch) VEXnet Joystick Configuration - ROBOTC Reference Programming Sense, Plan.
#Vex robotc programming code#
My Code is posted below: #pragma config(Sensor, in2, lightSensor, sensorReflection) View online(166 pages) or download PDF(18.92 MB) Vex CORTEX Programming. While the bump switch code block is running, I need the LEDs to light up and go off seven times for one second every time the Light sensor value gets higher than 400. The problem I'm having is getting the LEDs to light up correctly. I need to get my robot to be able to use the bump switches so that either one can be pressed and the motor corresponding to that bumpswitch will run for as long as the bump switch is pressed.
