0

Control each LED with different colors without EEPROM
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Control each LED with different colors without EEPROM

by noobie on Thu Sep 23, 2021 1:55 am

Hi,
I have 3 Neopixel LED rings that have 12, 16, and 24 LEDs and I am using Arduino for programming. I am using Serial Communication, the user selects the LEDs and the colors.

The requirements were:

    1) I should be able to control all the LEDs separately.

    2) I should be able to send different colors to any LED and they should stay in that state until I shut it down. For ex. I want first: red on the 1st LED on the 1st ring and then yellow on the second LED and then pink on the 3rd LED on the 3rd ring. My first problem was, figuring out how to light up the LEDs in any order at the same time. The one that was first selected; and then not selected: It was changing its color when I select another one with another color. But It should have remembered its state and should not change when I was selecting the other LED with another color.

After a really long time, I could manage these requirements by using EEPROM all the time. The pseudo-code:

Code: Select all | TOGGLE FULL SIZE
if (updateRing1Led[1]) {
EEPROM.update(given R and G and B) } ---> update the color
else{
EEPROM.read(given R and G and B)}     ---> Ring1Led1 is not selected; do not update; just read the color.


//Update the color in the selected LED.
//Do not update if the LED is not selected; just keep stay in the last color until selected.

if (the input is 1)
updateRing1Led[1] == true;
updateRing1Led[2] == false;

if(the input is 2)
updateRing1Led[2] = true;
updateRing1Led[1] = false;


Now; this is all working.
But; I got comments like this can be the best way to kill the EEPROM since I'm using these updates in the draw() section; because it should change according to the user input. But this was literally the only algorithm I could come up with for these requirements. So I have 2 questions:

    1 ) Is there a way to meet these requirements without using EEPROM? Maybe there is some functions I don't know about these rings.
    2) A noobie question but...What do you think, like how dangerous is this method, could it stop working in the middle of the project someday? And could it make the Arduino useless at any time?
    3) If I use Arduino Nano or Micro, would that be very problematic with this algorithm?

noobie
 
Posts: 5
Joined: Wed Sep 22, 2021 7:24 am

Re: Control each LED with different colors without EEPROM

by adafruit_support_bill on Thu Sep 23, 2021 5:27 am

The only reason to use EEPROM or other type of non-volatile storage is if you need to preserve the LED state through a power-off cycle. Otherwise, you can just create a variable in your program and store it there.

EEPROM typically has a finite lifetime of around 100,000 erase/write cycles before failure. So it is not a good idea to be continually writing to it.

adafruit_support_bill
 
Posts: 82079
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.