First let me state that I am a beginner so please keep your answers simple. Thanks
I have created 3 different projects for my Model Railroad. These are all on a ELEGO UNO
One project contains 5 LED's at different rates controlled by Millis.
Second project contains 2 LED's at different rates controlled by Millis.
At this point everything worked perfectly.
Added 3rd project which contains only one LED.
When I added this project I started to get a flicker from all the LED'S. I brought out my computer and reloaded the program. Everything worked fine. Flicker was almost gone. Computer was still hooked up.
When I switched to a New 9v battery the flicker returned.
"When I switched to a New 9v battery the flicker returned.
How can I correct this?"
Use a wall-wart for power. The flickering is likely the Uno shutting down, the battery recharging enough to restart, then shutting down.
If you put a simple Serial.print("."); in setup() when running off a battery, you should see a . every the Uno restarts.
This is a Farm house with a TV flickering in one room and different bedroom and living room lights going on at off at different times.
This is a warming barrel with a fire in it. Red and Yellow LED’s Flickering to create the fire.
The last one is a traffic light with a blinking yellow LED.
In a previous thread someone checked the code and told me even though is was not the standard
millis it would work fine. As I stated above the projects worked perfectly using this code. If I am on my computer everything works fine. I don’t want to have to hook up a computer every time I want to run.
The problem occured when I connected to the 9v Battery.
jremington:
9V block batteries are for smoke alarms, and can't supply enough power for the Uno and a bunch of LEDs.
In addition to the lack of capacity of the battery itself, the 5v regulator on the UNO was intended mainly to power the UNO itself, and has very little capacity for external loads.
If you must run off battery power, try a USB power bank connected to the USB connector on the UNO, there should be sufficient current draw from the LEDs to avoid the common problem of the power bank shutting off from too small of a load.
In reference to your question about a wall wart - use a USB charger, those are usually rated around an amp or more these days, supply 5 volts, and everyone seems to have spare ones lying around.
+1 for the USB or other 5V charger. You can connect it to the Arduino either through a USB connector, or through the 5V pin and GND, but not through RAW or the barrel jack.
OK I got lucky. I found and old computer laying around. I programed the arduino into it and copied the script. I installed it under my layout to be permanent. Everything works fine.
1.As I add more projects to this Arduino am I going to create the same problem?
Someone above mentioned I am using the wrong code for millis but as I stated It runs everything perfectly.
Should I be looking to change the Code as I move forward?
As soon as millis() + INTERVAL_1 overflows, time_for_action_1 becomes a very small number, and the if statement will be true every time through the loop until millis() itself overflows. As a practical matter, you will never encounter the problem since a model railroad layout is unlikely to be left running for fifty days, but it is best to do it properly so you will not implement it this way when it does matter.
The programs that run on Arduino are not scripts. Typically, a script is a text file containing command language instructions, that is processed in some operating system by a real time interpreter. The correct word for Arduino code is "sketch", you can also say "program" or "source code".