class LED – on-board LED#

The LED class drives the individual LEDs soldered onto every STM32-based OpenMV Cam. Most of those boards expose an RGB indicator LED plus a fourth status LED (IR illuminator on the imaging cams, a white illuminator on the Pure Thermal); the N6 has the RGB indicator only. Each LED is exposed as a separate, on/off-controlled object.

Typical use cases are status indication, frame-grab heartbeats, and turning the IR illuminator on for low-light captures:

import pyb
import time

red = pyb.LED(1)
ir = pyb.LED(4)

# Blink the red LED while the IR ring lights the scene.
ir.on()
for _ in range(5):
    red.toggle()
    time.sleep_ms(200)
ir.off()

Constructors#

class pyb.LED(id: int)#

Create an LED object associated with the given LED. id is the 1-based LED number; the colour/function and the number of LEDs present depend on the OpenMV Cam:

Camera

LED(1)

LED(2)

LED(3)

LED(4)

OpenMV Cam M4 / M7 / H7 / H7 Plus

Red

Green

Blue

IR

OpenMV Cam Pure Thermal

Red

Green

Blue

White

OpenMV Cam N6

Red

Green

Blue

The LED objects are simple GPIO wrappers: there are only three operations – on(), off() and toggle(). For colour blending, drive several LEDs at once (e.g. red + green for amber).

Methods#

on() None#

Drive the LED to its on state.

off() None#

Drive the LED to its off state.

toggle() None#

Flip the LED’s current state. If it was on it goes off, and vice versa. Useful for heartbeat blinkers in a polled loop or timer callback.