Neopixel auto strip number

Hello, I want to set up a neopixel LED test setup with an Arduino. The way I planned it, each pixel will flash each color in turn. Then I'll run another animation. The problem is that I may not be able to adjust how many LED pixels are connected during testing. What I want is for it to automatically update the pixel count as I add strips. It doesn't matter if it updates instantly, it can also be updated after rebooting. Do you think this is possible or how can it be done?

Hook the data out of the last strip to an input pin on the Arduino and count how many clock cycles it takes to shift a bit there? Not quite automatic - you would have to call it when you wanted a count.

That assumes that the strip buffer is empty. Even then it will not contain all the same characters because there is formatting information in it.

This has been asked a few times and I don't think a satisfactory solution has been found.

I can only think of adding a fast light sensor to the last light of the thread and clocking out data until it lights up.

This question implies you were considering changing strips while the Arduino is powered up.
never make changes to a circuit with it powered up
That is one of the best ways of burning things out.

Just don't go there unless you can make a connector that connects first the ground, then the power and finally the signal as you slide it in. In other words making it "hot plugable", like a USB connector.

Alternative idea, connect the output of the last strip into an input that feeds a hardware counter/timer. That should let you count the number of unused bits in the data stream. Most libraries that drive neopixels have rather tight timing requirements, and disable interrupts, so you need something that can accumulate a count under those conditions.

When using animations in the neopixel library I get an error when using the outer interrupts. Do you think this is because of the library?

Will there be any data to output after the last pixel in the strip ? My understanding is that each each pixel in a strip reads the first 24 bits it sees on its DIN pin, then copies any further bits to its DOUT pin

If that is the case then it would be necessary to monitor the DIN pin of the last pixel rather than its DOUT pin

Using a timer to count the unused pulses on DOUT looks quite nice to me.

An other idea is to measure the current draw... or the voltage drop caused by the current draw (see Measuring The Length Of WS2812 Strips | Hackaday)

It's the same data :wink: Just one pixel (24-bits?) later, and easier to hook-up to.

But the last LED does not output any data if the number of LEDs is set correctly in the sketch.

Each LED removes its data from the data stream and passes on the remainder. Once the last LED removes its data there is nothing to pass on and hence no output from its DOUT pin

Obviously it would be necessary to send data for at least one more than the maximum number of LEDs that would ever be used, unless you want to make the assumption that no data out of the last LED equates to the maximum number being present.

It is obvious once you realise it, but it was never mentioned when the method was suggested

You also cannot assume that no data output from the last LED indicates that the number of LEDs has been discovered unless you start by testing for at least one more than the total possible number and working your way down from there

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.