Ok, so i am really keen to try replicate this project here

I'm still a noob and my knowledge of electronics stretch as far as making a light blink using an Arduino (Maybe a bit more).

I was thinking of using a ATmega328 instead of the ATtiny24A, because I can program it using my Arduino Uno like explained here

So this leads me to my question, how do I use coin cell batteries to power the ATmega328, maybe more specifically, what components will I need and why?

  • 3
    \$\begingroup\$ It is possible to program a ATtiny24A with an Arduino. \$\endgroup\$ Nov 6, 2013 at 9:49
  • \$\begingroup\$ @Ignacio: Am I right in thinking that the "core" is what allows the Arduino IDE to target the code for the specific AVR controller but that the ArduinoISP sketch allows you to use an Arduino as programmer to program any AVR controllers, even those for which you have no core, so long as you do your coding outside the Arduino IDE. Ref \$\endgroup\$ Nov 6, 2013 at 9:56
  • \$\begingroup\$ @RedGrittyBrick: I am honestly not certain. I have a EvUSBasp (Baite USBasp clone) but no Arduino, so I've never actually used ArduinoISP myself. \$\endgroup\$ Nov 6, 2013 at 9:59
  • 1
    \$\begingroup\$ An ATmega328 may be a bit power hungry for a coin cell, especially if you don't use sleep modes. \$\endgroup\$
    – jippie
    Nov 6, 2013 at 10:02
  • \$\begingroup\$ @RedGrittyBrick, your explanation is exactly correct. Ignacios link points to a core for ATtiny, and ArduinoISP works for any AVR controller. ATtinies are not much harder to program than ATmegas, and for smallish projects, it makes sense to pick a sensibly sized controller for the job, an ATmega328 is often a bit overkill. \$\endgroup\$ Nov 6, 2013 at 13:19

3 Answers 3


You use coincells the same way you use any battery to power an AVR like the ATMega328p. You hook it up directly. That's it, nothing different. Positive to VCC & AVCC, Negative to VSS and AVSS.

Keep in mind, coincells have very little capacity, will drain quickly under 20+ milliamp load, so maximize the time you spend in power-save/sleep mode, and the low voltage will limit your clock speed to 4 or 8 or 10mhz at most.

enter image description here

enter image description here

  • \$\begingroup\$ A decoupling capacitor, (I don't know exactly what it is, so if someone can explain to me in layman's terms that would be great) would I need to have this? \$\endgroup\$
    – Donderbos
    Nov 6, 2013 at 12:06
  • \$\begingroup\$ @HenkScheepers a decoupling cap is like a small energy bank. If the power line drops down a bit, the cap kicks in to keep the line up. A 0.1uf cap is typically recommended. \$\endgroup\$
    – Passerby
    Nov 7, 2013 at 5:28

Just to amplify some of the rather important points made in comments ...

Use an ATtiny24 not an ATmega328

The project you want to copy uses an ATtiny24 for good reasons.

[The] ATtiny24A microcontroller ... included all of the things the team were looking for – it was working with voltages as low as 1.8V, consumed small amounts of current and had enough i/o pins.

ATtiny24 vs ATMega328

  • lower cost
  • smaller package (DIP-14 vs DIP-28)

It has plenty of GPIO pins (~12) compared to a DIP-8 ATtiny45 for example (5-6).

If you are making a large constellation of interacting autonomous objects, you can get more for your money by using parts that are no bigger/expensive than they need be.

If money, size and power-consumption are no object, you might use a 144-pin AT32UC3C064C for maximum future flexibility. Personally I think half the fun of this sort of project is squeezing it into a small device.

Loading software

You can use an Arduino Uno to program (load software onto) an ATtiny24 on a breadboard.

To do this you first load an "ArduinoISP" program ("sketch") into your Arduino Uno. You can then use this to load programs onto an ATtiny24 or any AVR microcontrollers that allow loading software via an ISP interface (I think there may be one or two that don't).

If your Arduino IDE isn't set up for the ATtiny24 (see below) there are other free tools to compile programs and free programs to load those programs onto an ATtiny24 - for example avrdude

Compiling software for an ATtiny24

You can use the Arduino IDE to write and compile programs to run on an ATtiny24. To do so you add a suitable "core" to your Arduino IDE's "hardware" subdirectory (folder). You can obtain a suitable "core" from code.google.

Note that many online tutorials mention the "core" from High-Low-Tech at MIT but that "core" doesn't include the ATtiny24 so try the code.google "core" instead.

Using coin-cell batteries

See other answers - You should choose a microcontroller no more powerful than the minimum needed to do the job. Set the clock speed low. Shut down unused features and make maximum use of low-current sleep states. AVR has documentation that specifically covers low-power applications.

  • \$\begingroup\$ Thanks for the breakdown, can you maybe elaborate on the reasons why you think the ATiny24 is better suited for the project. Say for instance I want to switch the LED with a RGB LED, will the ATiny24 supply me with enough I/O pins? \$\endgroup\$
    – Donderbos
    Nov 7, 2013 at 7:30
  • \$\begingroup\$ @Henk: See revised answer - follow links to Data Sheets. \$\endgroup\$ Nov 7, 2013 at 10:23
  • \$\begingroup\$ If you wish to use CR2032 batteries, have a look on this post: hackster.io/Talk2/… \$\endgroup\$
    – Talk2
    Dec 13, 2016 at 5:12

Other than what you would need to run it on a breadboard, you will need a coin cell holder. That is, you will still have the same bypass, filter, and clock hardware as described in AVR042, "AVR Hardware Design Considerations". Also keep in mind that you should probably restrict your clock speed to 8MHz for safe operation down to about 2.5V.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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