Using the VEX IQ Touch LED

Description

This sensor can detect capacitive touch, such as the touch of a finger. It can also be set to display many colors.

VEX IQ Touch LED piece.

The VEX IQ Touch LED Sensor is included in the VEX IQ Super Kit but it can also be purchased here.


How the Touch LED Works: Detecting Touches

Diagram of two Touch LEDs with voltage graphs below them. The first Touch LED is not being pressed and the graph's response signal is very similar to the input signal. The second Touch LED is being pressed by a finger and the graph's response signal is different than the input signal.

The Touch LED uses technology that detects small changes in the physical properties of its surroundings. It does this by measuring capacitance.

Capacitance is a physical property of any object. It can be affected by what a thing is made of, or what it's shaped like. The air around us has a certain capacitance, an electrical circuit has a certain capacitance, and your body has a certain capacitance.

The Touch LED can detect this capacitance by sending an electrical signal and noting what comes back. In the image you can see that when the button is pressed, the purple response signal changes compared to the blue input signal. If the response signal is just right, it means there is a finger present, and the Touch LED sends a message back to the Robot Brain which means that it's being touched.

One advantage of checking for touch in this way is that a change in capacitance does not require that you touch the circuit directly, only that you get very close. As a result, the electronics in the Touch LED can be shielded with plastic and packaged along with more electronics, like the multi-color LEDs inside the device.


Common Uses of the Touch LED:

  • This sensor can be used to start or pause a program at the touch of a finger, as shown in the animation below.

  • This sensor can be used to display different colors at different parts of a program, as shown in the animation below.


Uses of the Touch LED on a Competition Robot:

  • The Touch LED can be used to start a running program with a finger press.
  • Team members can see when different sections of an autonomous program are running by programming the Touch LED to display a unique color for each section.
  • Using the Touch LED can also be used to help troubleshoot programming problems if issues occur.

Using the Touch LED in VEXcode IQ

Adding the Touch LED as a Device in VEXcode IQ

VEXcode IQ Devices menu after the Add a device button has been selected. The Touch LED option is highlighted.

To code the Touch LED in a VEXcode IQ, you must first configure the Touch LED. View this article to learn more about configuring a sensor in VEXcode IQ.

Once the Touch LED is configured, commands will appear in the Toolbox that you can use in your project.

Coding the Touch LED in Blocks

Pressing Touch LED

VEXcode IQ Pressing touch LED block that reads TouchLED3 pressed?

The <Pressing Touch LED> block is a Boolean reporter block that reports a condition as either true or false. Boolean blocks, like the <Pressing Touch LED> block fit inside blocks with hexagonal (six-sided) inputs for other blocks.

The <Pressing Touch LED> Boolean block reports 'true' if the Touch LED is pressed, and 'false' if the Touch LED is released or not pressed. To learn more about Boolean blocks visit the Help or the Block Shapes and Meaning article.

Note: The name of the Touch LED that appears in the command corresponds to the name it is given in the configuration. 

VEXcode IQ blocks project that uses a Wait until block to drive 500mm each time the Touch LED is pressed. The project reads When started, forever: Wait until TouchLED3 pressed, and then drive forward for 500mm.

In this example, the <Pressing Touch LED> block is used with a [Wait until] block to make the robot drive forward for 500mm when the Touch LED is pressed, as shown in the video above. 

{When Touch LED}

VEXcode IQ When Touch LED block that reads When TouchLED3 pressed.

The <Pressing Touch LED> block is an Event block that will run the stack of blocks attached when the Touch LED is pressed or released. 

To learn more about Event blocks visit the Help or the Block Shapes and Meaning article.

VEXcode IQ blocks project that uses a When Touch LED block to drive 500mm each time the Touch LED is pressed. The project reads When TouchLED3 pressed, drive forward for 500mm.

In this example, the {When Touch LED} block is used with a [Drive for] block to make the robot drive forward 500 until the Touch LED is pressed, as shown in the video above. 

Touch LED Blocks in the Look Category

Three VEXcode IQ Touch LED blocks from the Looks category. The first is a Set Touch LED color block that reads set TouchLED3 color to none. The second is a Set Touch LED fade block that reads set TouchLED3 fade to slow. The third is a Set Touch LED brightness block that reads set TouchLED3 brightness to 50 percent.

Each of these blocks can be used to adjust the color shown on the Touch LED. 

[Set Touch LED color] is used to set the desired color of the Touch LED. 

[Set Touch LED fade] is used to set the desired speed of the fade of the Touch LED to slow, fast, or none. 

[Set Touch LED brightness] is used to set the desired brightness level of the Touch LED from 0-100%. 

To learn more about each of these blocks visit the Help.

VEXcode IQ blocks project that uses blocks from the Looks category to control the Touch LED's colors. The project reads When started, set TouchLED3 brightness to 100%, and then set TouchLED3 color to blue. Next, wait 2 seconds, set TouchLED3 fade to slow, and then set TouchLED3 color to red.

In this example, the Touch LED brightness is set to 100% and the color will first show blue for 2 seconds then slowly fade to red. These blocks can be used to display different colors at different parts of a project.

Coding the Touch LED in Python

Note: To code an VEX IQ (1st generation) Bumper Switch in Python, it must be connected to a VEX IQ (2nd generation) Brain. The VEX IQ (1st generation) Brain does not support Python.

TouchLED.pressing

touchled_3.pressing()

The TouchLED.pressing command reports a Boolean value of either true or false about the Touch LED.

The TouchLED.pressing command reports 'true' if the Touch LED is pressed, and 'false' if the Touch LED is released or not pressed. 

Note: The name of the Touch LED that appears in the command corresponds to the name it is given in the configuration. 

Touch LED Event Commands

touchled_3.pressed(callback)
touchled_3.released(callback)

The TouchLED.pressed and TouchLED.released commands runs a specified callback function when the Touch LED is pressed or released.

Touch LED Commands in the Looks Category

touchled_3.set_color(Color.BLACK)
touchled_3.set_fade(FadeType.SLOW)
touchled_3.setbrightness(50)

Each of these commands can be used to adjust the color shown on the Touch LED. 

Set TouchLED color is used to set the desired color of the Touch LED. 

Set TouchLED fade  is used to set the desired speed of the fade of the Touch LED to slow, fast, or none. 

Set TouchLED brightness  is used to set the desired brightness level of the Touch LED from 0-100%. 

To learn more about each of these commands visit the Help.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: