Basic Touch LED Programming


 


The Touch LED is a touch sensor and a color LED all in one. You can use it to let your robotic inventions interact with people. In this tutorial, you will be introduced to the Touch LED sensor and program it to turn on when touched. You will then use setup blocks in order to set the ON color of the Touch LED.

Hardware required

  • VEX IQ Brain
  • Touch LED

Program

Let's create a program that turns the touch LED on when touched and off when left untouched.

Open the Modkit for VEX editor. Drag and drop a Touch LED and assign its port number. Make sure it matches that of the physical Touch LED.

Next, click on the 'Blocks' tab and make sure that you are editing the Touch LED.Program the Touch LED to turn on when touched: drag and drop a 'When Start' block onto the screen. Click on the drop-down icon and select 'TOUCH LED-TOUCHED.' Drag a 'light ON' block underneath the 'when' block. This code will run once each time the Touch LED is touched.

Next, program the Touch LED to turn off when left untouched: drag and drop a second 'When Start' block onto the screen. Click on the drop-down icon and select 'TOUCH LED-UNTOUCHED.' Drag another ‘light ON’ block underneath this second 'when' block. Click on the drop-down icon and select ‘light OFF’. This code will run when the Touch LED is left untouched.

Download your program, and run it on the physical VEX IQ brain.

Next Steps

Use ‘Setup’ blocks to control the ON color of the Touch LED. The code below makes it green. Select any of the colors from the drop down list.

Download your program, and run it on the physical VEX IQ brain.

In this tutorial, you learned about the touch LED and programmed it to turn on based on touch. There is so much more that you can do! Check out our other Getting Started guides.

Updated 50 months ago