Touch LED#
Introduction#
The Touch LED includes blocks that control and monitor the VEX IQ (2nd gen) Touch LED. These blocks allow you to set color, brightness, and fade speed, as well as detect when the Touch LED is being pressed.
Below is a list of available 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? – Returns whether the Touch LED is currently being pressed.
when Touch LED – Executes the attached stack of blocks when the Touch LED is pressed or released.
set Touch LED color#
The set Touch LED color 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 :: hat events
[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
set Touch LED fade#
The set Touch LED fade 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 :: hat events
[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 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 :: hat events
[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? block returns if a Touch LED is currently being pressed or not pressed. This block returns a Boolean value:
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 :: hat events
[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 block runs the attached stack of blocks when the Touch LED is pressed or released.
when [TouchLED1 v] [pressed v] :: hat events
Parameters |
Description |
---|---|
touch led |
Which Touch LED to check, configured in the Devices window. |
actions |
Determines when the attached stack of blocks will execute:
|
Example
when [TouchLED1 v] [pressed v] :: hat events
[Turn green briefly when pressed.]
set [TouchLED1 v] color to (green v)
wait [2] seconds
set [TouchLED1 v] color to (none v)