Is it possible to query (or otherwise detect) if Arduino is connected to 60 NeoPixel strip vs 144 strip?

2017-11-14 23:25:42

Is there any way to have an arduino detect how many LEDs are on a connected strip? I have a 60 strip and 144 strip. The code is identical for both, aside from setting the number of LEDs in a variable to iterate over.

Neopixels only have one-way communication. Some possible ways to detect the quantity are:

Bring the Data-Out of the last pixel back to the arduino and activate an interrupt on an input pin connected to that. If you write 144 LEDs worth of data to the 144-LED strip, the pin doesn't change. If you write 144 LEDs worth to a 60-LED strip, the pin changes. So your code has a startup routine to write data and detect it. You can even write all "black" colors, since the data will still have HIGH and LOW values, and your detect routine won't show any light patterns.

Pass the ground line that goes to the LED strip through a low-value resistor (A current-sense resistor) and use an analog input to read the voltage across the resistor. Write an all-white color to

  • Neopixels only have one-way communication. Some possible ways to detect the quantity are:

    Bring the Data-Out of the last pixel back to the arduino and activate an interrupt on an input pin connected to that. If you write 144 LEDs worth of data to the 144-LED strip, the pin doesn't change. If you write 144 LEDs worth to a 60-LED strip, the pin changes. So your code has a startup routine to write data and detect it. You can even write all "black" colors, since the data will still have HIGH and LOW values, and your detect routine won't show any light patterns.

    Pass the ground line that goes to the LED strip through a low-value resistor (A current-sense resistor) and use an analog input to read the voltage across the resistor. Write an all-white color to all NeoPixels and sense the current draw. Pre-calculate the 144-LED current draw and 60-LED current draw and set a cutoff value for knowing which strip is connected.

    Make your LED-strip connector to have more pins than necessary strict

    2017-11-14 23:36:24
  • Not without effort. You could take the DOUT from the last LED, feed it back into the MCU, and then detect how long it takes to get some sort of signal from it, but this requires either the end of the chain being very close to the MCU or a long wire to connect them. Easier to just have a DIP switch to set the number of Pixels in the chain and go from there.

    2017-11-15 00:22:40