I'm pretty new to using the FastLED library on Arduino with my WS2812B led strip and using Arduino itself. I am trying to make it so I can turn my LED strip on and off, but a little different than that. I have many effects in my code, and I am able to switch between any of them using buttons and stuff. I want to be able to turn my led strip on and off but when I turn it back on, the led strip goes back to whatever effect I last had applied. Kind of like if you unplug the led strip and plug it back in, it's back to what it last was, but without unplugging it. Like no matter what my led strip looks like and what it's doing, I want it to go back to that after It's turned off and turned back on in the code. I know of "FastLED.clear();" and then "FastLED.show();" for turning off, but to turn it on, you usually have to set what you want your LED strip to look like before turning it back on.
I would really appreciate it if someone could help me out on this. Thanks!
Edit: I have my LED strip connected to an external 5v power supply, and it's not being powered by my Arduino Mega. So I don't think a simple digitalWrite could do the trick.
So it's all in the code. So we need to talk about your code. Where is it?
BTW, read the forum instructions in order to know how to post code here.
That is a very confused statement! An Arduino Mega 2560 does not, cannot ever power anything! It is a microcontroller board, never a power supply. digitalWrite is what your code uses to send data (though the FastLED library presumably bypasses that extremely slow function) via microcontroller pins, nothing whatsoever to do with power.
Even if it were appropriate - it clearly is not - to switch the power to your LED strip, you would need a FET suitably rated for the substantial operating current of the strip. But that would get you nowhere as you still need to re-program the strip whenever you turn it on.
Do note however, that with all black programmed to the strip, it does still draw about 1 mA per pixel; 300 mA for a 300 pixel strip.
The thing is, I haven't written any code to do this exact thing because I don't know how. Hence why I made this post.
Giving my code is irrelevant here because I am requesting code or code help, not trying to fix mine.
I am aware of this. I worded my post wrong. I am not using the power supply that powers my Arduino Mega 2560 to power the LED strip. I connected a separate power supply to power the LED strip. I did this because I have a 5v TFT LCD connected to the Arduino Mega 2560 so I can't use one power supply.
I am sorry for my confusion, but are you saying that I have to reprogram the strip to turn it back on?
Thanks for letting me know this. Is turning my whole strip black the only option to do what I am wanting to do? I would do it if I had to, even knowing it still draws power. I wouldn't ALWAYS have the LED strip plugged in though.
Again, sorry for my ignorance. I am still learning.
When you either code the LED strip to all black, or turn it off, it loses its "memory" (like RAM) of what it was displaying before. It should generally default to black when you turn the power on.
Well turning it off will certainly make it black, but that means adding components capable of handling the total power of the LED strip such as a suitably rated (non-trivial) FET or a relay. Much easier to tell it to go black.
You haven't specified how many LEDs.
Operating from mains power, 300 LEDs drawing 300 mA at 5 V while dark is 1.5 W, hardly going to add much to your power bill.
I am using a TFT LCD shield that connects directly to my board. It draws 5 volts, and since I am using a 5v power supply to power the board, I can't connect 2 components that both use 5v. Therefore I use two power supplies.
How do I prevent this? This is exactly what I am wanting to prevent. LED strips from big brands like Phillips have it so when you turn the strip off and on via Bluetooth or using a remote, it goes back to what you last had it set to. This is exactly what I want to achieve.
My bad. I have a 300 LED strip. Though I will be extending it with 2 more strips with 300 LEDs on each strip.
Which is why I don't mind if I had to turn the strip black programmatically rather than completely drawing the power from the strip (I don't know if turning the strip black programmatically is the same thing as drawing the power)
So how can I prevent the LED strip from losing its memory when I turn it off? Allowing the LED strip to remember its last state? I am unaware of any sort of products in which could be added to my project to do this exact thing..
If you are referring to LED strips using WS2812 or similar, then you presumably mean they have a controller that generates (relatively) simple patterns. The controller is "remembering" the last pattern it was told (by Flash/ NovRAM) and as soon as switched on, it starts feeding the corresponding codes to the strip. Or it remembers two alternatives - "OFF", which is all black, and a specified fixed or dynamic pattern.
At full white, 16.5 Amps per 300 LED strip.
It has no memory other than one single pattern. Turned off, that is erased.
An Arduino. When turned on, it sends whatever pattern you wish, to the strip.