1

Imagine a collection of LEDs (Neopixel or otherwise) labeled 2 through 12. There may be more than 11 LEDs, so repeat numberings are allowed. I want a simple way to control them from a single Arduino based on their label. So e.g. I should be able to implement a function whose arguments are a label value and an RGB value, and which turns all LEDs of that label value to the given RGB value. Most importantly, the solution has to be order-independent; that is, I should be able to re-wire the LEDs (or equivalently, scramble around the hex labels) in any manner, and still have everything work without rewriting any code. (For context, my goal is to make a custom Settlers of Catan edition, where the labels on each hex light up when their die value is rolled.)

I know I can't just use Neopixels out of the box, since the addressing depends on the order in which they're wired. So I assume I need to hack together a way for each LED to "know" its label, wire them all in parallel, and then write a custom library to . But I have no idea how to get each LED to know its label without having an entire Arduino for each LED, which would take up way too much space. (I'd like to fit everything in roughly the volume of a typical Catan hex label; think 2-3 quarters stacked together.)

I'm fairly comfortable with Arduinos, but I'm an electronics noob. Is it possible to reprogram the Neopixel controller? Or is there a tiny logic board I can hook up to a Neopixel or dumb LED that would do the job? Anything else I'm missing?

8
  • Neopixels are generally wired in a sequence. Can you please clarify how you are planning to wire these ones up?
    – Nick Gammon
    May 28, 2018 at 8:38
  • 1
    How do you plan on connecting the tiles (electrically)? You could just have a 12 pin connector on each of the sides of the tiles (actually 14 as you’d need Vcc and Gnd too). Or have a small micro controller, like an attiny85 on each tile and a regular rgb led. And control them over for example I2C.
    – Gerben
    May 28, 2018 at 8:39
  • what does this mean? based on their label
    – jsotola
    May 28, 2018 at 17:15
  • each LED to "know" its label .... they do not know .... the LEDs accept the first 24 bits after it is reset, and passes any other bits to the next LED ... after a reset, the second LED does not get any data until the first LED has "absorbed" the first 24 bits .... it is like a bunch of people and a deck of colored cards where each person takes a card from the top of the deck (each card represents a 24bit color)
    – jsotola
    May 28, 2018 at 17:44
  • Nick, that's part of the question. They need to be swappable in the way that regular Neopixels aren't. So e.g. wired in parallel.
    – Twiffy
    May 28, 2018 at 20:59

2 Answers 2

1

It will not be easy to “re-wire the LEDs [...] and still have everything work without rewriting any code.” Those LEDs are not that smart, and the only way to address them is by the order in which the color data is sent through the data line.

What you can do, however, is write the code is such a way that rewiring requires only a minimal change in the code. I would use an array to map the LED indices to their labels. Something like this:

const uint16_t LED_COUNT = ...;

// Map LED indices along the strip to hex labels.
const uint8_t ledLabels[LED_COUNT] = {
    2, 2, 2, 2,  // LEDs 0 to 3 are labeled "2"
    8, 8, 8, 8,  // LEDs 4 to 7 are labeled "8"
    // etc...
};

Then, assuming your LED strip is declared as follows:

const uint8_t LED_STRIP_PIN = ...;
Adafruit_NeoPixel ledStrip(LED_COUNT, LED_STRIP_PIN);

the “function whose arguments are a label value and an RGB value, and which turns all LEDs of that label value to the given RGB value” can be quite easily written:

// Turn all the LEDs sharing that hex label to the given color.
void setHexColor(uint8_t label, uint32_t color)
{
    for (uint16_t n = 0; n < LED_COUNT; n++)
        if (ledLabels[n] == label)
            ledStrip.setPixelColor(n, color);
    ledStrip.show();
}

Now, if you rewire the strip, you just need to update the ledLabels array and recompile. If you can manage to send that information to your Arduino while it's running (a serial connection, an IR link, an SD card inserted in an appropriate socket, whatever...), then you could even have a procedure where the Arduino updates the array itself. Obviously the const qualifier should then be removed. But you now have to devise a way to “tell” the Arduino about your wiring.

0

The data wires of individually addressable LEDs of various descriptions are typically wired as a daisy chain, with each LED driver having input and output for the data (and clock). Each LED driver will then manipulate the signal it sends onward to trick the next LED into thinking it is the first in the chain.

Most libraries to drive them can easily have a few 100 LEDs it can driver at a time depending on available RAM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.