Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Wednesday, February 13, 2013

Power consumption of Arduino

While the Arduino doesn't draw much power, the consumption does go up (significantly) if you throw a 7805 voltage regulator in the mix. Just because you don't actually see stuff happening, doesn't mean that the processor isn't at work. Even at full rest, an Atmel ATMega 328 powered through a 7805, does draw current. As my lights and sirens project demonstrates: one night of letting the box sit around without turning the main power switch off pretty much drained a 9V. Especially when the circuit is a toy for a 3-year old, it is hard to expect him to turn the thing off every time.

In order to address that, I updated my circuit a bit. After doing some searching, it was clear that the standby mode of the Arduino processor isn't good enough; it still draws power because of the voltage regulator. In order to address that, I came up with the following solution:


The 9V battery powers the voltage regulator in one of two ways. When the momentary push button is pushed, the circuit is closed and power is applied. That power will then initialize the processor, which in turn will set a pin to 5V. Setting the pin to 5V will engage the relay, which at that point closes the circuit for the 9V <-> 5V battery also. The momentary button can be released, since the relay is still active.

After some period of no activity, the processor can simply drop the pin to which the relay is connected to low, the relay disengages, and the circuit is broken, which cuts power to the voltage regulator, and as a result to the microprocessor.

As far as I can see now, the only drawback of this design is that the relay also draws a current. The model that I chose clocks in at around 24mA, which compares it to an LED. I could have countered that with a relay that latches, but those were too pricey for me.

All in all-- a solution that appears to work. And, with a timeout set to 2.5 minutes, hopefully less frequent battery replacements.

Friday, February 8, 2013

Arduino Lights and Sirens Final Product

I finished the final version of my Arduino Lights and Sirens project last night. I'll write up the software and the final build post later on, but I figured that I would at least share the results here.

The completed project box looks like this:


When it is actually running, you get the effect as shown below:




More details about the write-up at a later time.

Tuesday, January 29, 2013

Arduino Lights and Siren Prototype

The first step of building the Arduino Lights and Sirens is breadboarding a prototype. With all the components known, that is a fairly straightforward exercise, as shown below. Four LEDs connect via 220 Ohm current-limiting resistors to pins 2,3,6,7, leaving pin 4 and 5 for future expansion. Pins 8, 10, 11 and 12 are for the four momentary switches. Each switch is typically pulled to ground via a 10k Ohm resistor when it isn't pushed, and goes straight to +5V when pushed.

The speaker goes to pin 9. The schematic looks like this.


Note that the speaker cannot be on pin 8, since that is not a PWM port, and the tone() function will fail on that pin.

The beauty of the Arduino platform reveals itself here; you don't have to worry at all about power supplies, capacitors to get rid of AC, crystals to provide a reference clock, etc. All of that stuff will come when we move from breadboard to production board. For now, it is all provided by the Arduino board itself.

When the breadboard prototype is actually built. it doesn't look as clean as in the picture above, but everything does work very well.


Pictured above are only two of the four momentary buttons; the other two switches are just out of sight, as is the Arduino itself. The speaker at in the center has been rescued from an old speaker phone.

This is really all the hardware we will need for this project. Next, we'll discuss the software.

Arduino Lights and Sirens

I have recently set out to work on my next project; this time it is based on the popular Arduino Uno microcontroller. The life of my son, who is 3 years old, revolves around fire trucks, sirens and flashing lights. So, I figured that I'd build the ultimate light-and-siren assembly.

My vision is to build a box that has a bunch of colored LEDs to emulate the light bar of an emergency vehicle, and a little speaker in the box that can be used as a siren. The heart of the assembly will be an Atmel ATMega 328p microcontroller.

As far as control goes, I'm looking for a few switches and push buttons:

1. A master on/off switch to cut power to the microcontroller
2. A toggle switch to determine if the LEDs are on
3. A momentary push switch to operate an "air horn"
4. A momentary push switch to operate the siren
5. A momentary push switch to change the pattern in which the LEDs flash
6. A momentary push switch to change the pattern of the siren

I also want to have a parental control that I can use to turn the siren assembly completely on or off, regardless of what buttons are pushed. Most likely, that's going to be done via pushing a secret combination of buttons at start-up. Note that I'm using the momentary push button to turn the siren on, rather than a toggle switch.

Once the box has been prototyped, I'll move to a more permanent board; although the Uno's are cheap enough, I'd rather spend $3 on a replacement microcontroller than $20 to replace the Arduino. That will require a few extra components, but nothing fancy. The final project will be powered by a 9V block battery.

The first order of business will be to bread-board the hardware components. It should be fairly straightforward: each LED will have a resistor to limit the current to 20mA (the 328 is rated at 35 mA, so 20mA seems fair); the siren is going to be a 0.25 W speaker with an impedance of 25 Ohm that was salvaged from an old speaker phone. The push buttons will have a 10k resistor to pull them to ground when open.

The second order of business will be the software; I would like this thing to be extensible and usable by others, so decent code is going to be a requirement.