LED – Light-Emitting Diode

The SBC has a total of 4 LEDs, 3 of them are programmable and can be programmed at will.

Note

For details about where the LEDs are located you can check the SBC LEDs section.

Methods

class Led

The Led class manages SBC LEDs: LEDGREEN, LEDRED and LEDINTERNAL.
When the class is instantiated, all LEDs are set to 0.

write(pin_id, state)

Set LED state

Args:

pin_id: LED to set, it can be an integer (0, 1, 2) or string (“LEDGREEN”, “LEDRED”, “LEDINTERNAL”).
state: LED state. 0 or False to turn OFF, 1 or True to turn ON.

Example to turn LEDGREEN ON:
>>> import sbc
>>> led = sbc.Led()
>>> led.write( "LEDGREEN", 1)
toggle(pin_id)

Toggle LED state.
Toggle means to change the LED state without knowing it (0 –> 1, 1 –> 0).

Args:

pin_id: LED to toggle, it can be an integer (0, 1, 2) or string (“LEDGREEN”, “LEDRED”, “LEDINTERNAL”).

Example to toggle LEDINTERNAL:
>>> import sbc
>>> led = sbc.Led()
>>> led.toggle( "LEDINTERNAL")

Blink LED.

Args:

pin_id: LED to blink, it can be an integer (0, 1, 2) or string (“LEDGREEN”, “LEDRED”, “LEDINTERNAL”).
freq_hz: blinking frequency in Hz.

Example to blink LEDINTERNAL at 2Hz:
>>> import sbc
>>> led = sbc.Led()
>>> led.blink( "LEDINTERNAL", 2)

Blink LED N times at 10 Hz in loops of 1 second.

Args:

pin_id: LED to blink N times, it can be an integer (0, 1, 2) or string (“LEDGREEN”, “LEDRED”, “LEDINTERNAL”).
count: Number of blinks. This number should be <= 5.

Example to blink LEDINTERNAL 4 times each second:
>>> import sbc
>>> led = sbc.Led()
>>> led.blink_times( "LEDINTERNAL", 4)