Arşivlenmiş
1
0
Bu depo arşivlendi. Dosyaları görüntüleyebilir ve klonlayabilirsiniz ama işleme gönderemez veya konu veya değişiklik isteği açamazsınız.
keybrd/tutorials/tutorial_5a_LED_on_uC.md

108 satır
4.7 KiB
Markdown
Ham Normal Görünüm Geçmiş

2016-09-24 01:25:54 +00:00
Tutorial 5a - indicator LEDs
============================
2016-07-18 02:26:00 +00:00
Keyboards often have LEDs to indicate CapsLock, NumLock, and other states.
It's one of the first things we look at when a keyboard produces unexpected results.
Adding LEDs to the basic breadboard keyboard
--------------------------------------------
The breadboard keyboard modifies the basic breadboard keyboard described in [tutorial_1_breadboard_keyboard.md](tutorial_1_breadboard_keyboard.md)
Add components to the breadboard as shown in the picture.
2016-09-24 01:25:54 +00:00
The three clear plastic cylinders are red and yellow LEDs.
Each LED is in series with a 4.7k Ohm current limiting resistor.
LED anodes (the longer lead) are powered by pins 16, 17, and 21.
LED cathodes (the shorter lead) are connected to a grounded terminal strip.
2016-07-18 02:26:00 +00:00
!["LEDs"](keybrd_5_LEDs/LEDs_back.JPG "LEDs")
2016-09-24 01:25:54 +00:00
keybrd sketch with LEDs
-----------------------
The [keybrd_5a_LED_on_uC.ino](keybrd_5a_LED_on_uC/keybrd_5a_LED_on_uC.ino) sketch will run on the above breadboard keyboard.
2016-07-18 02:26:00 +00:00
As usual, the sketch annotations explain the code.
2016-09-24 01:25:54 +00:00
LED forward voltage
-------------------
Forward voltage is the voltage used by the LED.
Forward voltage is published in the LED's datasheet.
Most blue and green LEDs have about 3.3 forward voltage, which does not reliably illuminate on Teensy LC's 3.3 volts.
Most red and yellow LEDs have around 2.2 forward voltage.
So use red and yellow LEDs on Teensy LC.
Low-current LEDs can go as low as 1.6 forward voltage.
2016-07-18 02:26:00 +00:00
LED brightness
--------------
2016-09-24 01:25:54 +00:00
The amount of current (I) going through an LED is directly proportional to how bright it appears.
By picking the correct resistor, you have full control over how bright the LED appears.
2016-07-18 02:26:00 +00:00
2016-09-24 01:25:54 +00:00
Lets see how much visual difference resistance makes.
Replace an LED's 4.7k Ohm resistor with a 68 Ohm resistor.
2016-07-18 02:26:00 +00:00
Less resistance makes the LED brighter.
Too little resistance will burn out the LED.
2016-09-24 01:25:54 +00:00
The current supplied to an LED should always be limited by a resistor or some other device.
2016-07-18 02:26:00 +00:00
LED current limiting resistor values
------------------------------------
This formula calculates the minimum resistance for maximum LED brightness:
```
output-pin Supply Voltage Vs
LED Forward Voltage Vf
Forward Current If
2016-09-24 01:25:54 +00:00
From Ohm's Law, minimum current limiting restiance R = (Vs - Vf) / If
2016-07-18 02:26:00 +00:00
```
For Forward Current, use the smaller of:
* Current capacity of output pin
* Continuous Forward Current of LED
Teensy LC output-pin capacities are:
* four 20 mA pins (5, 16, 17, 21)
* nineteen 5 mA pins
* Teensy LC on-board LED is on pin 13.
It has a current-limiting resistor on the board, and does not provide enough power for another LED.
2016-09-24 01:25:54 +00:00
Voltages and current capacities are published in datasheets and sometimes pinout diagrams.
2016-07-18 02:26:00 +00:00
For Teensy LC 20 mA pin and the TT Electronics OVLLx8C7 LED:
```
output-pin Supply Voltage Vs = 3.3 volts
LED Forward Voltage Vf = 2.2 volts
2016-09-24 01:25:54 +00:00
use the smaller of:
2016-07-18 02:26:00 +00:00
max pin Current If = 20 mA
2016-09-24 01:25:54 +00:00
max LED Current If = 30 mA
2016-07-18 02:26:00 +00:00
minimum current limiting restiance R = (Vs - Vf) / If = 55 Ohms
```
2016-09-24 01:25:54 +00:00
Add a safety margin for resistor tolerances (1%, 2%, 5%, 10%), and round up to a standard value.
http://www.rfcafe.com/references/electrical/resistor-values.htm
```
55 Ohms + (55 Ohms * 10%) = 60.5 Ohms < 68 Ohms
```
2016-07-18 02:26:00 +00:00
It is safe to use more resistance.
Calculating the resistance for the Teensy LC 5 mA pin is left as an exercise.
Through-the-hole resistors have color coded bands that indicate resistance value.
https://en.wikipedia.org/wiki/Electronic_color_code#Resistor_color-coding
Exercises
---------
1) In this exercise you will calculate the minimum current limiting resistance needed for your output pin and LED.
2016-07-22 08:11:38 +00:00
For your microcontroller, find:
2016-07-18 02:26:00 +00:00
* Supply Voltage coming out of the output pins
* Current (mA) capacity of the output pins
From your LED's datasheet, find:
* Forward Voltage
* Continuous Forward Current (mA)
Calculate the minimum resistance needed for your LED and Supply Voltage.
<br>
2016-07-21 20:20:07 +00:00
<a rel="license" href="https://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by/4.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">keybrd tutorial</span> by <a xmlns:cc="https://creativecommons.org/ns" href="https://github.com/wolfv6/keybrd" property="cc:attributionName" rel="cc:attributionURL">Wolfram Volpi</a> is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.<br />Permissions beyond the scope of this license may be available at <a xmlns:cc="https://creativecommons.org/ns" href="https://github.com/wolfv6/keybrd/issues/new" rel="cc:morePermissions">https://github.com/wolfv6/keybrd/issues/new</a>.