1

I have a simple sketch running on a BE Leonardo-compatible board.

It reads input from a potentiometer, and outputs to two RGB LEDs which change colour over time - in a different pattern if certain inputs are received.

Other than that, the only code is serial I/O for debug purposes. (It's disabled using a #define in the running version, to prevent serial buffer overflow when not connected.)

When the board is powered by USB, everything works.

When the board is powered by 9V battery, after about 4 minutes it hangs - the LEDs go off, and the L13 light on the board starts glowing at varying strength. (There is nothing connected to pin 13.) Even the reset button doesn't work.

If the board is then connected to the computer's USB port, after a few seconds the hang clears and the program resumes.

Can anyone offer a possible explanation for (and solution to) this fault?

4
  • If I could I'd offer a bounty, because I need this thing running as a prop tomorrow night. Since I can't, I offer my heartfelt thanks to anyone who can help. ;) – Tynam Nov 17 '14 at 19:47
  • 1
    Try using a AA battery pack instead of a 9V. Or parallel 2 9V batteries together (not in series!). 9V batteries can't provide that much current. So your project is probably drawing near it's limit. Then after a few minutes the batteries voltage drops too low for the arduino, which resets. This continues starting, resetting will explain the board led flickering. – Gerben Nov 17 '14 at 20:06
  • @Gerben: Ah. That will be it. The draw should only be about 120ma (2 RGB LEDs), but perhaps the battery isn't fully charged. (For comparison, the same battery has run a project involving 2 2.5in 7-segment LEDs and a medium size servo for several hours... so I simply hadn't thought of it drawing low from 2 LEDs, even RGB ones.) (Heads off to try to figure out where he can fit in more batteries withot making a noticeable problem...) – Tynam Nov 17 '14 at 20:24
  • Could yo post the simple sketch so that we can check it cannot be the source of your problem? – jfpoilpret Nov 18 '14 at 5:35
4

As somebody else suggested, 9V batteries are pretty weak. They only provide a very small number of mAh (milliamp/hours) before their voltage starts to drop. Once the voltage drops to around 7 volts, the regulator in the Arduino can't keep providing 5 volts, so your Arduino resets.

Wire up 6 AA batteries in series. That will provide a much "stiffer" 9 volt supply (more instantaneous current) plus a lot more mAh of total power. If you REALLY want long life, wire up 6 C or D batteries in series, or an external 9V supply through a "wall wart" power supply.

2
  • Yep, this was it. (Unfortunately there was a reason for the 9V battery, and it was battery pack space, so the obvious solutions are not an option... but I can manage 2x9V parallel, and recode for power saving.) – Tynam Nov 18 '14 at 7:51
  • Instead of the second 9v, use a more efficient switching regulator. Also consider if you can make your application work at a slower clock speed and reduced voltage, or sleep your processor when it is not doing useful work. – Chris Stratton Nov 18 '14 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.