LED
RoboBoard X3 does not have dedicated LED. It is emulated trough RGB A.
Control interface for changing LED state and blinking.
Can be used with internal RoboBoard LED or external one connected to GPIO.
Code snippets
// Turn LED on
LED.on();
// Turn LED off
LED.off();
// Toggle LED between on / off
LED.toggle();
// Check if LED is on
bool isOn = LED.isOn();
// Make LED blink (5 times)
LED.blink();
Functions
Control
LED.on() ¶
-
Turn LED on.
LED.off() ¶
-
Turn LED off.
LED.toggle() ¶
-
Toggle LED between on / off states.
state
LED.isOn() ¶-
Get current LED state.
Returns:
state
- state on / off [true
:false
] LED.setState(
state
) ¶-
Set LED state on / off.
Parameter:
state
- on / off [true
:false
]. state
LED.getState() ¶-
Same as
isOn()
.
Returns:
state
- on / off [true
:false
].
Blink
LED.blink() ¶
-
Blink LED 5 times.
LED.blink(
count
) ¶-
Blink LED number of times.
Parameter:
count
- number of times to blink LED [1
,2
,3
, ...] LED.blink(
count
,onTime
,offTime
) ¶-
Blink LED number of times with custom on and off durations.
Parameter:
count
- number of times to blink LED [1
,2
,3
, ...]
onTime
- how long LED is ON (time ms) (default 100)
offTime
- how long LED is OFF (time ms) (default 200)
state
LED.wait()
¶
state
LED.wait(time
) ¶-
Halts code execution until LED stops blinking.
Contains timeout feature for maximum amount oftime
to wait.
Parameter:time
- maximum time to wait (ms) for LED blink stop.0
- disabled.
Returns:state
-true
if stopped,false
if timeout.
External GPIO LED
IOLED gpioLed(IO33); // LED connected to pin IO33
gpioLed.on(); // Turn LED on
IOLED gpioLed(GPIOA); // LED connected to pin GPIOA
gpioLed.on(); // Turn LED on
IOLED
can be used for external LED connected to any GPIO pin. It requires pin number and pin state when lit on (for algorithm to know when LED is on). All same functions are available as for LED
object.
Note: "blink()" can be used only with single LED at a time.
Constructor:
IOLED(pin
)
¶
IOLED(
pin
,onLevel
) ¶-
Create LED control object.
Parameter:
pin
- GPIO pin number
onLevel
- pin state when LED is on [LOW:HIGH]. Default - HIGH.
IOLED led1(IO33); // LED on pin IO33. Pin state HIGH to lit on
IOLED led2(IO33, HIGH); // LED on pin IO33. Pin state HIGH to lit on
IOLED led2(IO33, LOW); // LED on pin IO33. Pin state LOW to lit on