keybrd library is an open source library for creating custom-keyboard firmware.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly a požadavky na natažení.

tutorial_5a_LED_on_uC.md 4.8KB

před 7 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. Tutorial 5a - indicator LEDs
  2. ============================
  3. Keyboards often have LEDs to indicate CapsLock, NumLock, and other states.
  4. It's one of the first things we check when a keyboard produces unexpected results.
  5. Adding LEDs to the basic breadboard keyboard
  6. --------------------------------------------
  7. The breadboard keyboard modifies the basic breadboard keyboard described in [tutorial_1_breadboard_keyboard.md](tutorial_1_breadboard_keyboard.md)
  8. Add components to the breadboard as shown in the picture.
  9. The three clear plastic cylinders are red and yellow LEDs.
  10. Each LED is in series with a 4.7k Ohm current limiting resistor.
  11. LED anodes (the longer lead) are powered by pins 16, 17, and 21.
  12. LED cathodes (the shorter lead) are connected to a grounded terminal strip.
  13. !["back"](keybrd_5a_LED_on_uC/back.JPG "back")
  14. keybrd sketch with LEDs
  15. -----------------------
  16. 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.
  17. LED forward voltage
  18. -------------------
  19. Forward voltage is the voltage used by the LED.
  20. Forward voltage is published in the LED's datasheet.
  21. Most blue and green LEDs have about 3.3 forward voltage, which does not reliably illuminate on Teensy LC's 3.3 volts.
  22. Most red and yellow LEDs have around 2.2 forward voltage.
  23. So use red and yellow LEDs on Teensy LC.
  24. Some low-current LEDs have 1.6 forward voltage.
  25. LED brightness
  26. --------------
  27. The amount of current going through an LED is directly proportional to how bright it appears.
  28. By picking the correct resistor, you have full control over how bright the LED appears.
  29. Less resistance makes the LED brighter.
  30. Too little resistance will burn out the LED.
  31. The current supplied to an LED should always be limited by a resistor or some other device.
  32. LED current limiting resistor values
  33. ------------------------------------
  34. In the section we will compute the minimum resistor value for maximum LED brightness.
  35. This formula calculates the minimum resistance:
  36. ```
  37. output-pin Supply Voltage Vs
  38. LED Forward Voltage Vf
  39. Forward Current If
  40. From Ohm's Law, minimum current limiting restiance R = (Vs - Vf) / If
  41. ```
  42. Voltages and current capacities are published in datasheets and sometimes pinout diagrams.
  43. Teensy LC output-pin capacities are:
  44. * four 20 mA pins (5, 16, 17, 21)
  45. * nineteen 5 mA pins
  46. * Teensy LC on-board LED is on pin 13.
  47. It has a current-limiting resistor on the board, and does not provide enough power for another LED.
  48. Continuous Forward Current of TT Electronics OVLLx8C7 red or yellow LED is 30 mA.
  49. Plug the numbers into Ohm's Law:
  50. ```
  51. output-pin Supply Voltage Vs = 3.3 volts
  52. LED Forward Voltage Vf = 2.2 volts
  53. For Forward Current, use the smaller of:
  54. current capacity of output pin If = 20 mA
  55. continuous Forward Current of LED If = 30 mA
  56. minimum current limiting restiance is R = (Vs - Vf) / If = 55 Ohms
  57. ```
  58. Add a safety margin for resistor tolerances (1%, 2%, 5%, 10%), and round up to a standard value.
  59. http://www.rfcafe.com/references/electrical/resistor-values.htm
  60. ```
  61. 55 Ohms + (55 Ohms * 10%) = 60.5 Ohms < 68 Ohms
  62. ```
  63. It is safe to use more resistance.
  64. Calculating the resistance for the Teensy LC 5 mA pin is left as an exercise.
  65. Through-the-hole resistors have color coded bands that indicate resistance value.
  66. https://en.wikipedia.org/wiki/Electronic_color_code#Resistor_color-coding
  67. Exercises
  68. ---------
  69. 1) In this exercise you will calculate the minimum current limiting resistance needed for your output pin and LED.
  70. For your microcontroller, find:
  71. * Supply Voltage coming out of the output pins
  72. * Current (mA) capacity of the output pins
  73. From your LED's datasheet, find:
  74. * Forward Voltage
  75. * Continuous Forward Current (mA)
  76. Calculate the minimum resistance needed for your LED and Supply Voltage.
  77. 2) See how bright an LED can get.
  78. In the above breadboard keyboard, replace an LED's 4.7k Ohm resistor with a 68 Ohm resistor.
  79. Make sure use a controller pin with a 20mA capacity (Teensy LC pins 16, 17, 21 have a 20mA capacity).
  80. <br>
  81. <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>.