I am trying to turn on a specific LED using the NeoPixel module. How it works is really easy: Parse it a 2D array of RGB colors. Here's an example:
require("neopixel").write(NodeMCU.B2, [[255, 0, 0], [0, 255, 0], [0, 0, 255]]);
That will turn on the first three LEDs with red, green, and blue. I want to have a function, where I can do something like:
function single(number, color) {
require("neopixel").write(NodeMCU.B2, number, color);
}
single(0, [255, 0, 0]);
single(1, [0, 255, 0]);
single(2, [0, 0, 255]);
Which would do the exact same as above. Now you might ask: Why would you want that? Well:
- I want it to remember the last "configuration" of LEDs, so I can update it over time
- If I want to turn off all my 100+ LEDs and just turn on the last few (or the ones in the middle), I wouldn't have to parse the
write()
function 100+ LEDs, where most of them are black
Is something like that possible, or would I have to do some magic in order to remember the last LED configuration?