adding on/off switch to arduino uno

does anybody know how to add an on/off switch on an Arduino uno so I can turn the power off and on when I want? I need to know because I am making blinking eyes for my first cosplay, and I really don't want to just have the batteries constantly run down when I am not wearing it! also, I need to know where I put it and I also need to know how many batteries it should take. I just need enough until it works right. I am going to use a metal gear servo motor, connected to an Arduino uno. does the on/off switch need to have its own code? or can I just put it where the negative and positive power pins are located?

I think your best bet is to put a simple mechanical switch (nearly any kind) in series with the positive lead of the battery to Arduino board.

There are other options that are move involved but the switch is likely you best bet at this point.

how many batteries will it take? the Arduino website said the recommended voltage is 7-12 volts dc to just power the uno. and I want this to run on batteries. I was going to keep adding up batteries until iget the desired operation, but I was afraid of it being broken when I may put too much power or less power. I don't have my Arduino uno and motor yet. I will buy it soon though!

bopitlover12:
how many batteries will it take? the Arduino website said the recommended voltage is 7-12 volts dc to just power the uno. and I want this to run on batteries. I was going to keep adding up batteries until iget the desired operation, but I was afraid of it being broken when I may put too much power or less power. I don't have my Arduino uno and motor yet. I will buy it soon though!

What batteries are you using? Do you have a volt meter? If not, get one.

Paul

bopitlover12:
does the on/off switch need to have its own code?

No.

bopitlover12:
can I just put it where the negative and positive power pins are located?

Yes.

It is fairly common for microcontroller-based devices to have a "soft" power switch. This is a button connected to one of the IO pins. The button press alternately signals the microcontroller to go into sleep mode or wake up. So this sort of power switch actually does require code. Although the device will continue to draw current even in sleep mode, in a well-designed circuit this current will be so low as to still offer years of battery life when off. But the Uno is not designed for low power consumption. If you were to only put the microcontroller to sleep, the batteries would continue to be drained quite quickly. It's probably easiest to get low power consumption by making your own Arduino board from scratch. It is possible to make a Pro Mini use the minimal current with only a couple small modifications, but that requires desoldering surface mount components which are fairly close to other components you want to leave be.

bopitlover12:
How many batteries will it take? the Arduino website said the recommended voltage is 7-12 volts DC to just power the UNO.

But you are not going to " just power the UNO" so that is now nonsense. You do not power the UNO for "real" projects via the "barrel jack" or "Vin"; you power it with 5 V (but 4 V will do) via the "5V" terminal.

Get a battery box with a switch.

bopitlover12:
I want this to run on batteries.

Well, you need the right batteries for the job. The servo will run on five to six Volts. The Arduino will run on 5 V but not significantly more. A pack of four AA Alkaline batteries will power the servo perfectly but is too much for the Arduino but a pack of three will produce 4.5 V which will run the Arduino just fine. So you could use two different battery packs which is actually, a very good way to do it.

Alternatively, you can use four Nickel-Metal Hydride rechargeable cells to give 5 V and probably run both servo and Arduino from a single pack.

bopitlover12:
I was going to keep adding up batteries until I get the desired operation, but I was afraid of it being broken when I may put too much power or less power.

Sensible enough in itself - to be afraid that is!

bopitlover12:
I don't have my Arduino UNO and motor yet. I will buy it soon though!

Good. Just as well. Do not buy a UNO. Buy a Nano. For this sort of project you must be able to solder, so either you have a soldering iron and the paraphernalia that go with it, or you have a friend or Maker group who has the equipment.

actually, im fine with that considering it still draws a small amount of current, because when I am done wearing the costume, I will take the batteries out and leave them out until I want to wear it again! and, since you said it draws a small amount of current, that's with anything if you leave the batteries in, and the device is off, and, what most manufactures, it says on the box, "if you are not using this device for more than a week, take the batteries out as is makes them last longer and to prevent corrosion." and, as I was researching what board was perfect to use, the uno is what I should use because it has a short circuit protection, but the nano does not, and the code for the nano and uno is the same but the pin configurations for my blinking eyes code that is already made on an instructable that I will modify it to my needs is different on the nano, and, I figured out, well, it will take a long time figuring out what pin it goes to! so, I am going with the uno. and also the uno is arduinos most popular board ever used by a lot of people! so that's why im using the uno!

bopitlover12:
actually, im fine with that

Fine with what?

bopitlover12:
considering it still draws a small amount of current

If you have a hard power switch it will not be drawing any current at all.

bopitlover12:
that's with anything if you leave the batteries in, and the device is off

Not if it has a hard power switch. And even if it has a soft power, if it's properly designed the minimal sleep power consumption will be so low that the shelf life of the batteries will be past before it could drain them.

bopitlover12:
what most manufactures, it says on the box, "if you are not using this device for more than a week, take the batteries out as is makes them last longer

I've never seen that. Must be a garbage product.

bopitlover12:
and to prevent corrosion

That certainly is good advice, but only for very long term. Many old electronics products have been ruined because they were stored for decades with batteries that leaked and corroded the circuit board.

bopitlover12:
the uno is what I should use because it has a short circuit protection, but the nano does not

You can add a PTC if you want that.

bopitlover12:
the code for the nano and uno is the same but the pin configurations for my blinking eyes code that is already made on an instructable that I will modify it to my needs is different on the nano, and, I figured out, well, it will take a long time figuring out what pin it goes to!

Nope. The Nano and Uno use the exact same pin mapping.

bopitlover12:
so, I am going with the uno. and also the uno is arduinos most popular board ever used by a lot of people! so that's why im using the uno!

Suit yourself. I know that for a costume I would absolutely want to use the smallest possible Arduino board but if you want to haul around an Uno and deal with the female headers then that's fine.

since you know about electronics, you should know to ALWAYS take the batteries out of your devices if your not going to use it for a long time. that makes the batteries last longer and it also prevents corrosion. if you don't know to do this always in your life, all of your prized possessions that you've had for a long time and you love so much will be perminantly RUINED FOREVER!!!!! YOU WILL NEVER GET YOUR THINGS BACK IF THEY ARE RUINED BY CORROSION. when you get another one of your device, it will not be the same as your first one. it will act totally different and look different.

Obviously I do know that since it's exactly what I said in my last reply.

So why is he coming and asking us questions here?


Oh!

Seems we should have examined his other thread before getting involved.

"She" is coming here to figure out the challenging dynamics of the world of making Cosplay from scratch and how to power the specific parts that she would like to move...I am her mom and she is my princess warrior who defied all odds of being here-and deals with a lot of issues daily-one including Atypical Aspergers…

She has chosen animatronics as her micro-focus, specifically FNAF characters, which lands us here. She is learning how to navigate through this new, exciting and fun-filled world-sometimes making the journey to get to the destination harder by not being able to see the big picture as easily as others, overlooking the beginning steps as well...This is good interaction for her as well as far as having conversations with people and by no means whatsoever does she mean anything by the way her words come out...

I (mom) greatly appreciate everything you guys have given her advice-wise! She is having a blast interacting with other people who share similar interests...

I monitor everything for obvious reasons, but felt compelled to let you know why she was asking the things in the way that she was...she wanted me to do this as well, saying "I just want help."

Thank you for reading! Have a great day! (Mom)

OK then, well then the "take home message" is that if you have not already purchased the Arduino for this particular project, get the Nano rather than the UNO.

The code is identical because the actual chip is the same, and you must solder connections for reliability in this sort of project. The "protection" afforded to the power input on the UNO only applies to the USB connection.

i know the code is the same for both uno and nano, but are you sure the pin configuration is the same? because I looked and it is different on the nano.

Please explain what you think is different.

Of course the Nano has a different form factor than the Uno but it uses the same microcontroller with the same pin mapping so you can run the same code on either board and have identical results.

The Nano actually has an advantage over the Uno in that it offers two more analog input pins.

Don't let this Uno vs. Nano thing sidetrack you from your project. I think the Nano is a great board and well suited for the projects you're interested in but it looks like the FNaf characters will offer plenty of room to hide an Uno away if you prefer working with that board.

Hi,

Sounds like a great project.

Before you talk about batteries;

  1. You are using two servo driven mechanical eyes.
  2. Can you post link to specs/data on the servos?
  3. What extra devices, lights etc do you have to power off the battery?
  4. Don't forget that even though the servo may be stationary, it may still be consuming significant current to maintain that position.

Thanks.. Tom.... :slight_smile:

ok. I must have gotten the info of the different pin mapping on nano from "yahoo answers". and maybe only one person said it was different. but, I will use the nano since it is smaller and it doesn't take up as much space in the foam of the head. that and I will go with the smallest electronic parts possible, expecially in a cosplay because those big huge parts will take up most of your space and maybe press against your body and not feel comfy and worst of all, you might get injured if those parts bump against your body very hard.

TomGeorge:
Hi,

Sounds like a great project.

Before you talk about batteries;

  1. You are using two servo driven mechanical eyes.

you really only need 1 servo to power the blinking eyes, because i saw a youtuber who made a very simular cosplay and she used one servo, and a arduino nano, and wire clothes hangers for the eye lifting mech. so basically there will be the one motor on the right side, (if the cosplays eyes are facing forward AKA looking forward.) and the wire close hanger will be shaped as 2 squares, one for each eye, and the eyelids will be glued on the squares, then the wire clothes hanger will fit right inside the little hole of the servo, and the other side will fit in something round, so it can rotate freely. and then the motor simply moves up and down, creating the blink!

anybody who reads this, I am halfway done with the head, I already shaped it, and all I have to do is buy my nano and micro usb adaptor so I can copy the code and modify it and then cut out the compartments where everything will go and then I will start fleecing the head! (YES, im using fleece, because it is very comfy and doesn't fray when I cut it, and fur is too hot and expensive and it sheds, and fur doesn't look right on a fnaf cosplay, unless you want to use your imagination and if you want it furry! and felt frays and gets ugly hot glue spots where the hot glue soaks in on it!) and then I will make the body, and then, I will post my cosplay on the Arduino website for everybody to see! and on my youtube channel! the reason why I will wait until I cut the compartments for the mech out to be able to fleece it is, if I were to fleece it now, and then cut the compartments out, I might ruin my beautiful fleece job!