class LED – LED Control

The LED class provides an interface to control the on-board LED.

Example usage:

from machine import LED

r = LED("LED_RED")
g = LED("LED_GREEN")
b = LED("LED_BLUE")

r.on()
g.off()
b.toggle()

Constructors

class machine.LED(pin_name) LED

Access the LED associated with a source identified by pin_name. This pin_name may be a string (usually specifying a color), a Pin object, or other value supported by the underlying machine.

Methods

LED.boardname() str

Returns the name of the board.

LED.on() None

Turns the LED on.

LED.() -> None

Turns the LED off.

LED.toggle() None

Toggles the LED state.

LED.value(v=None) int

If v is given, sets the LED to the given value. If v is not given, returns the current LED value.