Hi. Super new user here. I have an Uno which I am using to blink some LEDs in a model.
Is there a way to use a simple slide switch to turn the unit on & off without having to go inside the model to pull the plug?
Is it necessary to have code for this?
It seems to me like the switch would just go between the board and the lights. This method works in my simulation, but not with real hardware.
IS there some reason you can't switch off the power to the Arduino?
Paul
A regular power switch goes in-between the power supply and the board.* If you're using a wall-wart power supply you'll need to splice-into the wires.
It seems to me like the switch would just go between the board and the lights. This method works in my simulation, but not with real hardware.
Your method will turn-off the LEDs, but the board will still be running. If the switch is not turning-off the LEDs, either it's wired wrong or it's defective because with an open ground the LEDs won't come on.
Or if you want to keep the Arduino powered-on and running, you can use a switch on an input pin (as in the Digital Read Serial Example**) with an if-statement to do one thing if the switch is on and another thing if the switch is off.
- A lot of modern stuff is constantly powered-on, but it's probably not necessary in your application. For example, your TV is always powered-on (in a low power state) so it can respond to the remote control.
** Actually, it's easier to use the [u]built-in pull-up resistor[/u] and reverse your connections and your logic (the switch pulls the input low when it's on). That way you don't need the external resistor.
My real issue is power. I was looking for ways to hook up a battery. What I read was that USB was really the safest source. I came across someone who was using a USB power pack (for recharging your phone on the go).
So now, instead of a battery which I could interrupt with a switch, I have a USB pack that, as you say, will still be powering the board even if the lights are off. So that's not really what I want.
Am I going at this wrong? Should I be using a regular battery & switch?
I'm going to a show next week. The unit should stay on for about 8 hours at a time while on display.
This is my very first Arduino project, so I am not as literate as most of you. Thanks for your patience.
Just put a switch in the battery wire, before the Arduino. Or disconnect the battery pack/powerbank.
As long as you draw enough power a USB power bank will work fine and is an easy solution, but if your power draw drops to a very low level (no LED on) for some time (half a minute or so usually) the power bank will switch off its output. So do test this beforehand.
Or you could get a battery holder with a switch. Here's a 4 aa cell pack, which will run your Arduino when it goes into the Vin pin (I know, I know, it's not optimum), or this 3 aa cell pack, which would go into the 5V pin.
firebird967:
My real issue is power. I was looking for ways to hook up a battery. What I read was that USB was really the safest source. I came across someone who was using a USB power pack (for recharging your phone on the go).
So now, instead of a battery which I could interrupt with a switch, I have a USB pack that, as you say, will still be powering the board even if the lights are off. So that's not really what I want.
Switch the power pack OFF at the mains outlet.
Tom...
Will this work... reasonably safe?
It will work - but not as long as AA batteries and the 9V battery may have a hard time powering that many LEDs, depending on how much current each LED takes.
TomGeorge:
Switch the power pack OFF at the mains outlet.
Tom...
Doncha just love the English language?
There are six 3mm LEDs. 20mA
Should I use 9v or some AA's?
I'll bring extra batteries; not a big deal. I just want them to stay on for a few hours at a time.
firebird967:
Will this work... reasonably safe?
http://www.instructables.com/id/Powering-Arduino-with-a-Battery/
Better to get an aa pack, which you can put the same kind of switch on the line - aa batteries will easily run 6 LEDs for 8 hours.
As for "reasonably safe", of course. I prefer lithium aa and aaa cells. Unless you try to recharge them, all batteries are inherently safe. Even the rechargeable kind, as long as they are recharged properly.
What sized resistors do you have between the LED and power/ground? You may not be running them at full current (with modern LEDs, you don't have to - they are nearly as bright as they can get at substantially less than 20mA.)
Battery life is measured in mAh - milliamp hours. It tells you how many milliamps the battery can supply for an hour. So for example, a 9 volt battery has approximately 200 mAh, while a lithium aa cell has 3000 mAh. Your circuit draws 30mA for the arduino, + 6 * 20mA for the LEDs = 150mA. The 9 volt will last a little over an hour.
Ah, I was forgetting the board itself.
Sounds like I should use AA batteries.
Would it be better with 4?
I have a 100 ohm resistor on each LED.
firebird967:
Ah, I was forgetting the board itself.
Sounds like I should use AA batteries.
Would it be better with 4?
I have a 100 ohm resistor on each LED.
Three is optimum if you use lithium, 5 volts on the nose, lasts for days.
The Arduino board should run just fine at 4.5V or slightly below.
With 100Ω resistors your LEDs will take about 20 mA for blue or white; you can increase those to 200Ω and reduce the current by half; your LEDs will be a little less bright but not too much different. If good enough for your application, that would almost double battery life (that is, if the LEDs are always on).
I ordered a 4x AA battery holder.
I tried with two AAs last night (in the 3.3v terminal), and it only lasted about 20 min.
In the mean time, my board has been running steadily off a USB phone charger for 4 hours now.
I have no idea how the internal connections are for power supply on the 3.3V pin, but I do know that it's not intended for such use on an Uno. You may kill the 3.3V regulator, and other odd effects may happen.
Also 3V is too low a voltage for an ATMega328 at 16 MHz. You have to clock it down to 8 MHz, 12 MHz should also still work but it's the limit. 4xAA will work fine on the Vin pin. 3xAA should work well when connected to the 5V pin. The powerbank through the USB socket is also directly connected to the 5V pin.
Just thought I'd check in to thank everyone for their suggestions. I wound up using 4 AA batteries and a little slider switch. It lasted a good 15 hours. It will probably will last more, but that's all the time it was on display.
Again, big THANKS everyone!
firebird967:
Just thought I'd check in to thank everyone for their suggestions. I wound up using 4 AA batteries and a little slider switch. It lasted a good 15 hours. It will probably will last more, but that's all the time it was on display.
Again, big THANKS everyone!
Bravo, and congratulations!