Hello everyone!
I am using Arduino UNO to execute a simple program that turns the first LED on an LED strip to red, then waits for 1s and turns the second LED to green. This seems to work when the Arduino is powered from the USB, but when I power it from a 5V battery, only the first LED glows red. It looks like the delay() call is permanently blocking execution when using a battery. I played around with the delay value, and the issue seems to be happening when the value is >= 9 ms
Any idea why the delay() is working when the Arduino microcontroller is powered from a USB, but not from a battery? Are there any workarounds or steps to resolve this issue?
I would expect the LED to be red over 99% of the time since there is only a few microseconds between setting the LED to green and setting it to red again. About once a second you may see a slight flicker.
That should give you about one second of red alternating with about one second of green instead of about one second of red alternating with a few microseconds of green.
Thanks for all the responses. Yes, the original code was trying to light up 10 LEDs with a 1s delay after each LED being lit. This worked fine with USB power, but with battery power only the first LED was glowing. So I was trying to isolate the problem, and it came down to the use of the delay() function. BTW, I changed the battery to a brand new 9V Duracell, and it worked fine.