Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Led strip

  1. #1

    Led strip


    I want to create a musical instrument that shows a led for each key. A bit like this, but not in a piano.
    Click image for larger version. 

Name:	img-ce-gallery-kks-mk2_overview_visual-feedback_gallery-a-5db5b1d09cbc03d9a42608888d940be4-d.jpg 
Views:	40 
Size:	68.9 KB 
ID:	23130

    I want to know if it is possible to control cheap led strips (very common on aliexpress... for example 5V strips having 3 pins WSxxxx ) from a Teensy board.
    What I need is :
    - Approx one meter led strip
    - Need to address every led separately by code
    - connect directly the pins from the led strip directly to the Teensy board, without any external component, boards...
    - Leds should be powered from the Teensy USB.

    How many LEDS can I power from USB? Is it possible to lower the power of each LED by code, to be able to light more LEDs?

    Regards !


  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts
    In general yes you can do this, but at some point you might run into power issues.

    The main variant of LED strings are WS2812B/SK6812 compatible. WS2812B is from the original manufacturer (World Semi or SK6812 is from a different manufacturer (Shenzhen LED Color Co.,LTD or Both LEDs use the same protocol, so you can use them interchangeably. In general, the WS2812B's tend to be stricter in terms of voltage requirements (3.7 volts to 4.3 volts, 17mA max power per LED), while SK6812's can be powered with more lenient voltages (3.3 volts to 7.5 volts, 18mA per LED). With WS2812B's, you generally have to transform the 3.3v data to 5v for the LED to run correctly. With SK6812's, you can run a small number of LEDs directly from 3.3v.

    In translating the voltage, you need to use a voltage level shifter that is fast enough, because the protocol works at a fixed speed. The normal level shifters used for I2C/SPI devices are too slow for WS2812B's, but there are fast level shifters.

    Note, the Teensy LC has one level shifter built-in that is explicitly for WS2812B's LEDs. That is the Teensy I would recommend if you aren't going to do audio processing. The level shifter output is at the back of the Teensy LC, and it translates data from the pin A3 (16) to the voltage from the USB adapter. For the LC, you would connect VIN to the power of the strip, the back pin to the data, and one of the ground pins to the ground.

    Now in terms of power, you generally can get about 500mA from a normal USB connection. This would translate to using about 22 LEDs if you used full power white (all 3 colors at max). But for each pixel, you can supply a value between 0 and 255 for each of the red, green, blue colors. If you reduce this power, you will be able to use more LEDs. So if you wanted all 88 keys, you might want to reduce the power to a max of 20..25 or so (the max is the sum of the 3 color powers). This will also be helpful to your users, as full brightness is generally too powerful.

    If you have SK6812's, if you set the max power to 10 or so, you might be able to power your LEDs from the 3.3v power and pin directly. The 3.3v pins can supply about 250mA. This way you don't need to use a level shifter (or the Teensy LC).

    The usual library people use when starting out is Adafruit_Neopixel (Neopixel is the name Adafruit uses for its led strings, that were originally WS2812B, and now are SK6812's). I tend to feel that if I'm using Adafruit libraries, that I should use some amount of Adafruit gear as well to help pay for the effort to make the libraries. There are other libraries that you can use.

    In general, when you start getting up past 50 or so LEDs, you have to pay more attention to things like powering the LEDs. In addition if you are doing things besides running the LEDs, the Adafruit_Neopixel library while simple may prevent the other things from running.

  3. #3
    I did that already in the past. True power issues are a problem if you want to light up entire strip, but to light up only a few leds out of say 4 octave keyboard (48 leds) (usually you don't have more than 10 FINGERS to play) I found out that I could easily live with 500mA power supply. Also a dedicated low-cost Arduino Nano/Micro is cheaper and better suited for the task (no need for level shifter). Delegating the work of driving the LED to dedicated arduino would free up computing resources of Teensy to do something more sophisticated. You can communicate which leds you want to light up via Serial or I2C.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts