class LED – portable on-board LED control¶
The LED class is a thin portable wrapper around
machine.Pin that drives a named board LED, hiding the
active-low / active-high wiring difference between boards. It is
shipped as a frozen Python module by the OpenMV firmware (see
scripts/libraries/machine.py) and is therefore available on
every OpenMV-supported board, regardless of port.
The LED is driven as a simple on/off GPIO; there is no PWM intensity
control. For LEDs wired to PWM-capable pins drive them via
PWM directly instead.
Example usage:
from machine import LED
red = LED("LED_RED")
red.on()
red.toggle()
red.off()
Constructors¶
- class machine.LED(pin_name: str | Pin) LED¶
Construct an
LEDobject bound to the LED identified bypin_name.pin_nameis either an OpenMV-board LED string ("LED_RED","LED_GREEN","LED_BLUE","LED_IR"– the exact set depends on the cam) or aPinobject.The constructor records whether the LED is wired active-low or active-high (using
boardname()to look up the active-level convention for the current board) so callers always pass logical on/off levels without worrying about polarity.Methods¶