LED

From Sketching with Hardware at LMU Wiki
Revision as of 13:16, 12 August 2020 by Skwhadmin (talk | contribs) (Created page with "= Description = LEDs are most common as simple visual output. LED stands for light-emitting diode (https://en.wikipedia.org/wiki/Light-emitting_diode). LEDs have 2 connectors...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

LEDs are most common as simple visual output. LED stands for light-emitting diode (https://en.wikipedia.org/wiki/Light-emitting_diode).

LEDs have 2 connectors: anode (+, long leg) and cathode (-, short leg)

The direction in which the LED is put into the circuit is important. For the forward direction and this is what we want, as this is when the LED is lighting up, the cathode (-, short leg) has to go towards 0V/GND and the anode (+, long leg) towards 3.3V/+/VSS.

A LED typically requires a resistor that is in series with the LED to restrict the current that is flowing through the LED.

For an LED we are interested in the following parameters:

  • the forward voltage (typically about 2V)
  • the forward current (typically about 20mA = 0,02A)

How to connect it electrically

images goes here... todo

How to control it in MicroPython

1 from machine import Pin
2 # assume our LED is connected to Pin 26, we use it as output 
3 myLED = Pin(26, Pin.OUT)
4 # this switches the LED on
5 myLED.on()
6 # this switches the LED off
7 myLED.off()

A small Program in MicroPython

 1 from machine import Pin
 2 from time import sleep 
 3 
 4 # assume our LED is connected to Pin 26, we use it as output 
 5 myLED = Pin(26, Pin.OUT)
 6 
 7 while True:
 8       # this switches the LED on for 1 second
 9       myLED.on()
10       sleep(1)
11       # this switches the LED off for 500 ms
12       myLED.off()
13       sleep(0.5)