You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 3.2KB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # WS2812Serial - Non-Blocking WS2812B / NeoPixel LEDs Library
  2. Similar to [OctoWS2811](https://www.pjrc.com/teensy/td_libs_OctoWS2811.html), this library
  3. allows you to use WS2811, WS2812, WS2812B / NeoPixel LEDs without blocking interrupts.
  4. ![](extras/ws2812serial.jpg)
  5. Non-blocking allows other libraries, especially
  6. [Audio](https://www.pjrc.com/teensy/td_libs_Audio.html) and high speed serial communication
  7. to function properly while the LEDs update. Complex animation can also run faster,
  8. because the show() function does not wait for the LEDs to update, allowing your code
  9. more time to draw the next frame.
  10. ## Hardware Resources Used
  11. WS2812Serial controls a single LED strip, using only 1 pin. While any number of
  12. LEDs may be connected, in practice 1 pin is best for small projects with less
  13. than 600 LEDs. OctoWS2811 offers 8 parallel outputs for large projects.
  14. Non-blocking performance does come with a cost. 15 bytes of memory are required
  15. per LED, rather than the usual 3 bytes with [FastLED](http://fastled.io/) or
  16. [Adafruit NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel). One of
  17. the [hardware serial ports](https://www.pjrc.com/teensy/td_uart.html) is also
  18. used to transmit the data, making that port unavailable for other uses.
  19. ## Supported Pins & Serial Ports
  20. | Port | Teensy LC | Teensy 3.2 | Teensy 3.5 | Teensy 3.6 | Teensy 4.0 |
  21. | :------ | :---------: | :--------: | :--------: | :--------: | :--------: |
  22. | Serial1 | 1, 4, 5, 24 | 1, 5 | 1, 5, 26 | 1, 5, 26 | 1 |
  23. | Serial2 | | 10, 31 | 10 | 10 | 8 |
  24. | Serial3 | | 8 | 8 | 8 | 14 |
  25. | Serial4 | | | 32 | 32 | 17 |
  26. | Serial5 | | | 33 | 33 | 20,39? |
  27. | Serial6 | | | 48 | | 29 |
  28. Serial2 & Serial3 on Teensy LC are not supported, due to lack of configurable
  29. oversampling needed to run at the high speed required.
  30. Serial3-Serial6 should be used only with CPU speeds 120 or 180 MHz.
  31. Serial6 on Teensy 3.6 is not currently supported, due to different hardware
  32. registers.
  33. If more than one object instance is created, each must use a different
  34. serial port, and each must have its own buffer memory.
  35. ## 5 Volt Data Signal Level
  36. WS2812 / NeoPixel LEDs are meant to use 5 volt signals. Most of WS2812 LEDs
  37. made before 2014 or after 2015 can use 3.3V signals, which Teensy LC and 3.x
  38. output. But a buffer chip to boost the signal to 5 volts is still the best
  39. practice.
  40. Teensy LC has a 5V buffer chip built in, connected to pin 17. The best way
  41. to use this buffer is leave pin 17 unused by your program (the pin defaults
  42. to a low power disabled state), and connect the data signals from
  43. pin 24 (or any other supported pin) to pin 17. Then connect the WS2812 LEDs
  44. to the 5V signal output.
  45. ![](extras/teensylc_5v.jpg)
  46. For Teensy 3.x, a separate 5V buffer chip should be used. Unidirectional
  47. buffer chips like
  48. [74HCT245](https://www.fairchildsemi.com/datasheets/74/74VHCT245A.pdf) and
  49. [74AHCT125](https://www.adafruit.com/product/1787) are best. Do NOT use
  50. [these mosfet transistor level shifters](https://www.sparkfun.com/products/12009).
  51. They are far too slow for WS2812 LED data.