pyb.LED.rst 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. .. currentmodule:: pyb
  2. .. _pyb.LED:
  3. class LED -- LED object
  4. =======================
  5. The LED object controls an individual LED (Light Emitting Diode).
  6. Constructors
  7. ------------
  8. .. class:: pyb.LED(id)
  9. Create an LED object associated with the given LED:
  10. - ``id`` is the LED number, 1-4.
  11. Methods
  12. -------
  13. .. method:: LED.intensity([value])
  14. Get or set the LED intensity. Intensity ranges between 0 (off) and 255 (full on).
  15. If no argument is given, return the LED intensity.
  16. If an argument is given, set the LED intensity and return ``None``.
  17. *Note:* Only LED(3) and LED(4) can have a smoothly varying intensity, and
  18. they use timer PWM to implement it. LED(3) uses Timer(2) and LED(4) uses
  19. Timer(3). These timers are only configured for PWM if the intensity of the
  20. relevant LED is set to a value between 1 and 254. Otherwise the timers are
  21. free for general purpose use.
  22. .. method:: LED.off()
  23. Turn the LED off.
  24. .. method:: LED.on()
  25. Turn the LED on, to maximum intensity.
  26. .. method:: LED.toggle()
  27. Toggle the LED between on (maximum intensity) and off. If the LED is at
  28. non-zero intensity then it is considered "on" and toggle will turn it off.