BO.io.LED Class
Creates an interface to an LED. This object provides helpful methods for blinking and fading LEDs. To use the fading methods, the LED must be connected to a PWM pin on the I/O board.
PLEASE NOTE: To use the fade methods, or to use an waveform other
than Oscillator.SQUARE
the LED must be connected to a PWM pin.
SOURCE_DRIVE
vs SYNC_DRIVE
. If the Anode (longer LED pin) is
connected to the microcontroller pin, then it is SOURCE_DRIVE
. If the
Cathode is connected to the microcontroller pin, then it is
SYNC_DRIVE
.
Constructor
BO.io.LED
-
board
-
ledPin
-
driveMode
Parameters:
-
board
IOBoardA reference to the IOBoard the LED is attached to.
-
ledPin
PinA reference to the Pin the LED is connected to.
-
driveMode
NumberThe drive mode of the LED. Must be set to
LED.SOURCE_MODE
orLED.SYNC_MODE
.SOURCE_MODE
is default.
Item Index
Properties
- intensity
- LED.SOURCE_DRIVE static
- LED.SYNC_DRIVE static
Methods
blink
-
interval
-
times
-
wave
Parameters:
-
interval
NumberThe time interval to blink the LED.
-
times
NumberThe number of times the LED should blink. A value of 0 will blink forever.
-
wave
FunctionThe waveform to apply (default is Oscillator.SQUARE)
fadeIn
-
time
The LED must be connected to a PWM pin to use this method.
Parameters:
-
time
NumberThe fade-in time (in milliseconds).
fadeOut
-
time
The LED must be connected to a PWM pin to use this method.
Parameters:
-
time
NumberThe fade-out time (in milliseconds).
fadeTo
-
to
-
time
The LED must be connected to a PWM pin to use this method.
Parameters:
-
to
NumberThe new intensity value to fade to.
-
time
NumberThe fade time (in milliseconds).
isOn
()
Boolean
Check if the LED is on.
Returns:
True if the LED is on, false if it is off.
off
()
Turn the LED off.
on
()
Turn the LED on.
stopBlinking
()
Stop the LED blink cycle.
toggle
()
Toggle the LED on or off.
Properties
intensity
Number
Get or set the current value (intensity) of the LED.