This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

pyb.LED

Classes

LED

Create an LED object associated with the given LED:

Module Contents

class pyb.LED.LED(id)

Create an LED object associated with the given LED:

  • id is the LED number, 1-4.

intensity(value: Any | None = None) None

Get or set the LED intensity. Intensity ranges between 0 (off) and 255 (full on). If no argument is given, return the LED intensity. If an argument is given, set the LED intensity and return None.

Note: Only LED(3) and LED(4) can have a smoothly varying intensity, and they use timer PWM to implement it. LED(3) uses Timer(2) and LED(4) uses Timer(3). These timers are only configured for PWM if the intensity of the relevant LED is set to a value between 1 and 254. Otherwise the timers are free for general purpose use.

off() None

Turn the LED off.

on() None

Turn the LED on, to maximum intensity.

toggle() Incomplete

Toggle the LED between on (maximum intensity) and off. If the LED is at non-zero intensity then it is considered “on” and toggle will turn it off.