Preview Mode. Sign in to save progress!
You are in preview mode! Progress will not be saved!
Sign in to save your progress!

Introduction: Move Until Touch

In this lesson, we will use the Touch LED to display green while the robot is driving forward, tap to stop, then display red when stopped.

Step 1: Open VEXcode Project

Open the "MoveUntilTouch" VEXcode project you created in the Robot Configuration page.
VEXcode IQ

Step 2: Add Set TouchLED Color Block

From the Looks Palette, drag a “set [SideLED] color to (none)” block. Set the color to green.
Add Set LED Color Block

Step 3: Add a Drive Forward Block

Drag a “drive [forward]” block to your program.
Add Drive Forward Block

Step 4: Add Wait Until Block

From the Control Block Palette, drag a “wait until” block to your program.
Add Wait Until Block

Step 5: Add TouchLED Boolean Block

From the Sensor Palette, draw a “[SideLED] pressed?” block to your program. Place it inside the “wait until” block.
Add Touch LED Block

Step 6: Add Second Set TouchLED Color Block

From the Looks Palette, drag a “set [SideLED] color to (none)” block. Set the color to red.
Add Second Touch LED Color Block

Step 7: Add Stop Driving Block

Drag a “stop driving” block to your program.
Add Stop Driving Block

Step 8: Download and Run

Tap the Touch LED at any time while the robot is moving forward. Make sure your robot is connected to your programming device, download and then run the program.
Download and run

Step 9: Observe

After running the program, the LED displays green and the robot moves forward. When the Touch LED is touched, the LED turns red and the robot stops.

Did You Know? Using Signals

Having a way to tell where the robot is in a program can be really helpful, especially when troubleshooting. Programmers often use different types of signals between behaviors so that it is clear where the robot is reading the program and what it is executing. We can use the Touch LED as a signal for this purpose. We just used the LED to show green while moving forward and red when stopped.
Adding Signals
A "wait until" block...
Contact Us