Touch LED#
Introduction#
The VEX IQ Touch LED is both a light and a button. It can glow in different colors to give feedback, such as signaling that the robot is ready, showing which mode is selected, or matching a color detected by another sensor, and it can detect when it’s being touched, letting you start or change a robot’s behavior with a tap.
Below is a list of all blocks:
set Touch LED color — Sets the Touch LED to a selected color.
set Touch LED fade — Sets how quickly the Touch LED transitions between colors.
set Touch LED brightness — Sets the brightness level of the Touch LED.
Touch LED pressed — Reports whether the Touch LED is currently being pressed.
when Touch LED — Runs the attached stack of blocks when the Touch LED is pressed or released.
set Touch LED color#
The set Touch LED color stack block sets the color of the Touch LED using the current transition speed and brightness settings.
set [TouchLED1 v] color to (none v)
Parameters |
Description |
|---|---|
touch led |
Which Touch LED’s color to set, configured in the Devices window. |
color |
Sets the LED’s color to:
|
Example
when started
[Blink the TouchLED off and on.]
forever
set [TouchLED1 v] color to (green v)
wait (0.5) seconds
set [TouchLED1 v] color to (none v)
wait (0.5) seconds
when started
[See what color the Optical Sensor is detecting.]
forever
set [TouchLED1 v] color to ([Optical1 v] color name)
wait (0.5) seconds
set Touch LED fade#
The set Touch LED fade stack block sets how fast the Touch LED will transition between colors.
set [TouchLED1 v] fade to [slow v]
Parameters |
Description |
|---|---|
touch led |
Which Touch LED’s transition speed to set, configured in the Devices window. |
transition speed |
The speed at which the Touch LED will transition to the next color:
|
Example
when started
[Slowly fade TouchLED colors.]
set [TouchLED1 v] color to (green v)
set [TouchLED1 v] fade to [slow v]
wait (2) seconds
set [TouchLED1 v] color to (red v)
set Touch LED brightness#
The set Touch LED brightness stack block sets the brightness of the Touch LED.
set [TouchLED1 v] brightness to (50) %
Parameters |
Description |
|---|---|
touch led |
Which Touch LED’s brightness to set, configured in the Devices window. |
brightness |
The brightness of the Touch LED from 0 to 100 as a percent. |
Example
when started
[Light up the TouchLED with different brightnesses.]
set [TouchLED1 v] brightness to (25) %
set [TouchLED1 v] color to (green v)
wait (2) seconds
set [TouchLED1 v] brightness to (100) %
Touch LED pressed#
The Touch LED pressed Boolean block reports whether a Touch LED is currently being pressed.
True — The Touch LED is being pressed.
False — The Touch LED is not being pressed
<[TouchLED1 v] pressed?>
Parameters |
Description |
|---|---|
touch led |
Which Touch LED to check, configured in the Devices window. |
Example
when started
[Change the TouchLED color when it is pressed.]
set [TouchLED1 v] color to (green v)
wait until <[TouchLED1 v] pressed?>
set [TouchLED1 v] color to (blue v)
when Touch LED#
The when Touch LED hat block runs the attached stack of blocks when the Touch LED is pressed or released.
when [TouchLED1 v] [pressed v]
Parameters |
Description |
|---|---|
touch led |
Which Touch LED to check, configured in the Devices window. |
state |
When the attached stack of blocks will run: pressed will run when the Touch LED is pressed down, and released runs when the Touch LED is released. |
Example
when [TouchLED1 v] [pressed v]
[Turn green briefly when pressed.]
set [TouchLED1 v] color to (green v)
wait [2] seconds
set [TouchLED1 v] color to (none v)