2016-06-07 22:57:41 +01:00
|
|
|
.. currentmodule:: pyb
|
2014-11-04 18:25:20 +00:00
|
|
|
.. _pyb.LED:
|
|
|
|
|
2014-10-31 22:21:37 +00:00
|
|
|
class LED -- LED object
|
|
|
|
=======================
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
The LED object controls an individual LED (Light Emitting Diode).
|
|
|
|
|
|
|
|
|
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
|
|
|
.. class:: pyb.LED(id)
|
|
|
|
|
|
|
|
Create an LED object associated with the given LED:
|
2019-12-04 04:02:54 +00:00
|
|
|
|
2014-10-31 01:37:19 +00:00
|
|
|
- ``id`` is the LED number, 1-4.
|
|
|
|
|
|
|
|
|
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: LED.intensity([value])
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
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``.
|
|
|
|
|
2016-01-29 23:06:13 +00:00
|
|
|
*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.
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: LED.off()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Turn the LED off.
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: LED.on()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
2014-12-16 11:55:46 +00:00
|
|
|
Turn the LED on, to maximum intensity.
|
2014-10-31 01:37:19 +00:00
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: LED.toggle()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
2014-12-16 11:55:46 +00:00
|
|
|
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.
|