Arduino led Christmas decoration power problem

I have made a simple Christmas decoration that fades some LEDs arranged in a tree pattern, the whole thing is on some strip-board sitting on top of the arduino, when I plug a battery into it it seems to work fine but after a while the LEDs switch off and the power LED on the board starts "flashing" (it switches between bright and dim every half second) a similar thing sometimes happens with the "L" LED.

It seems to work fine when plugged into USB, I have tried this on two boards (A Duemilanove and an Uno) and the same thing happens, only when plugged into a 9 v battery, unplugging the battery and plugging it in again immediately doesn't help, if you leave it for a few minutes then it works again. I have no clue what else could be wrong.

Please help, thanks.

Measure the battery voltage, could be its low. Then recharges itself some after being off. 9v batteries not know for high current capacity. Try 3 AAs or 3 C cells connected to gnd & VCC instead for longer life. Pololu makes nice little triple AA battery packs, even some with on/off switch.

Or see if you can find some kids toy you can pull out of. I have one that powered some toy in demo mode, hung onto it after the kid unpacked the toy, has come in handy.

All I have handy at the moment is 9v batteries, they all measure above 7v, most are still at 9v and none works in this project, I will try with some AA when I have some, I will also have to get a 3xAA holder from somewhere to see if this solves the problem.

Thanks for the quick reply.

If they're not measuring 9V they're on the dead side. You're losing power by having the 9V regulated down to 5V by the onboard regulator. If you can bring in 4.5V directly, you'll get longer life.

thanks again, I will buy a 3xAA box and use that.

they all measure above 7v, most are still at 9v and none works in this project,

Batteries should be loaded when being measured. The voltage is meaningless unless you have it attached to your project when you measure it.

I know what is happening now, I attached a volt meter to the battery and measured the voltage while it was attached to the arduino with this Christmas decoration on it, the LEDs were working and the battery measured 8.5 v, I left it there until it started to 'misbehave' and checked the voltage again, it was now on 3v (2volts too short) after unplugging the battery from the arduino the meter went straight up to 7v, plugging it back in again immediately made it jump back down to 3v, I left it unplugged for 5 minutes and plugged it in again, this time it went from 7v slowly down towards 3v, it started to misbehave again and the green 'L' light flashes every few seconds, every time the light flashed the meter jumped slightly (about a quarter of a volt) befor returning to 3v.

It would seem that the capacity of the battery is the main problem here. This should be easy to fix with a better battery.

Thanks for all your help. ;)

You know what I just saw at Home Depot? Emergency backup lighting batteries. 6V, 4 AH. That would last a long time! Would have to come up with your own charger for it. Get 3 C or D cells, that will last a long time as well, maybe hack a flashlight as a holder :-)