Monday, 31 December 2012

Fun with Arduino - Arduino on a Breadboard

How to remove the 'Arduino' from your Arduino project


In this tutorial, we are going to build a 'stand-alone' circuit that will allow you to run your Arduino code without an actual Arduino board.

The term Arduino actually refers to a system of components that include the board, the microcontroller, the boot-loader ,and the programming environment. It is a system designed to 'protect' the user from a lot of the complication that is part of microcontroller programming.

At the heart of the Arduino board is a microcontroller called the ATMEGA328P. The Arduino board acts like a space suit for the ATMEGA, providing life support and doing its best to protect the chip from damage.

At the end of the day, the Arduino is a development board. While you can make the Ardino a permanent part of you project, once you have finished with the development phase of your design, it is often cleaner and less expensive to replace it with a stand alone ATMEGA microcontroller circuit. This is what we are going to build.

The Arduino board has built in power regulation circuitry that provides a steady 5 Volts to the ATMEGA328P. But, since the Arduino is going bye-bye, we have to build our own power supply circuit. We also need to provide a clock source for the microcontroller.  The 16Mhz crystal and 22pF capacitors take care of that.

Parts required:

1 - 9v DC Power Adapter - 500ma or greater (Wall Wart)
1 - DC Power Socket (2.1mm or sized to fit the plug of your power adapter)
1 - LM7805 - 5 Volt regulator
1 - 1N4001 - rectifier diode
1 - 100uF (Micro-Farad) electrolytic capacitor - rated at 25v or more
1 - 10uF (Micro-Farad) electrolytic capacitor - rated at 25v or more
2 - 22pF ceramic capacitors
1 - ATMEGA328P microcontroller
1 - 16 Mhz crystal
Hook-up wire (22 Gauge - Solid)

(Optional)
1 - SPST Switch
1 - 220 ohm resistor
1 - LED

How it works


First take a look at the schematic.



Let's look at what this circuit is doing. The 9 volt power from your adapter is being fed to a 1N4001 diode. This diode will only allow current to pass in one direction so if the adapter is connected backwards, the circuit will be protected. The 7805 regulator then drops the voltage down to 5 volts and holds it there. The 10uF and 100uF smooth out any ripples in the 5 volt supply.

This steady 5 volt power is supplied to the ATMEGA328P chip. The 16Mhz crystal and 22pf capacitors supply a steady clock signal to the microcontroller. Finally, in 10K resistor holds the microcontrollers 'reset' pin high, so the chip will run it's program. It's a very simple circuit.

Choose your Power


A couple of notes about choosing a DC Power adapter. This circuit will accept a variety of power adapters, but 9 volts is a good choice. You could go a little higher but the extra voltage will just be wasted as heat from the 7805 regulator. You may need to add a Heat-Sink if you go too high. If you go lower than 9v you may find the regulator may have difficulty putting out it's full 5 volts.

Also check the current rating of the adapter. I am using a 500mA unit. This is a fair choice as it is the same rating as the USB port that was probably powering your Arduino not long ago. If your project is larger, you may want to go with a 1 amp unit.

Finnaly, check the polarity of your adapter. Most adapters have a symbol printed on the label that shows the polarity of the tip and sleeve of it's power plug. You can see the symbol in the photo below. This one is showing that the sleeve of the plug is positive. You can use either type, just make sure you wire up your jack accordingly.



Build it


This video provides a step-by-step guide to circuit construction.



You should now have a funtional ATMEGA chip on your breadboard happily running your Arduino program.

In the next tutorial, we are going to look at programming the microcontroller directly on the board. See you then.

61 comments:

  1. may I ask... why isn't the ISP socket used in the video ?

    ReplyDelete
    Replies
    1. Hi there. Thanks for stopping by. The ISP socket is included in the schematic to make the circuit workable even off of a breadboard. The breadboard is basically a giant socket so to add another socket on it is unnecessary.

      Delete
    2. thanks man!

      Delete
  2. Thanks a lot! I used your multisim diagram in my project report :P

    ReplyDelete
  3. Big THX! May I ask... Can i use instead of 25V capacitors 16V and 3.3V regulator instead of 5V? (And of course, it will be powered by a 2-6V)

    ReplyDelete
    Replies
    1. Hi There. 16V caps should be fine. I have not tested running from 3.3V but there may be issues trying to run it with the 16 Mhz crystal at that voltage. Also, you would want to use a 3.3v programmer.

      Delete
    2. Thx again. What do you recommend to use crystals with 3.3V?

      Delete
  4. Hi. I'm sorry Dave.

    I was thinking in make my personal Synth. But I have a just question:

    Is possible add a sequencer, the style drum machine?

    Sorry again, big thanks!

    ReplyDelete
    Replies
    1. Hi There. Anything is possible with a little ingenuity. What synth project are you working on?

      Delete
  5. I have tried the same method bot it gives an error:
    Error while burning bootloader,
    avrdude: Yikes! Invalid device signature.
    Double check connections and try again, or use -F to override
    this check.
    please help me...

    ReplyDelete
    Replies
    1. Same problem for me... :(
      ------------------
      Arduino: 1.6.5 (Mac OS X), Board: "Arduino Uno"

      Build options changed, rebuilding all

      Sketch uses 1,556 bytes (4%) of program storage space. Maximum is 32,256 bytes.
      Global variables use 265 bytes (12%) of dynamic memory, leaving 1,783 bytes for local variables. Maximum is 2,048 bytes.

      avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

      avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x01
      avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0x10
      avrdude: initialization failed, rc=-1
      Double check connections and try again, or use -F to override
      this check.

      avrdude: stk500_disable(): unknown response=0x12
      Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
      ------------------

      Got the same error also when burning the bootloader (I tried even though it already should have an arduino bootloader delivered by factory - maybe is that what causes me the problem now?).

      Delete
    2. I got this same error: Turned out a bent one of my legs on the chip and it did not seat. Look for the obvious first as I was looking for a solutin for 2 days before I realized I was an ass!

      Delete
    3. i,ve tried two different chips and both come up with a similar error.

      Delete
  6. Does it have to be a 9v wall wart? Could we just use a 5v wall wart and skip the voltage regulator?

    ReplyDelete
    Replies
    1. That would be dangerous. Most wall warts are not regulated so their actual output voltage can be very different from their printed rating. You could easily blow up stuff.

      Delete
    2. Does the voltage regulator affect the amps?

      Delete
    3. It's complicated. Think of your circuit as a resistance (load) that you are attaching to the wall wart. The lower this resistance, the more current will flow.

      The voltage of the wall wart will drop as more current flows. So when you see an adapter with a rating of say (5 volts, 200 mA) what it is actually saying is "This adapter will output at least 5v as long as you are not drawing more than 200mA".

      If you swapped this adapter with one rated at 5v,500mA. The voltage to your circuit would be higher. That's why a lot of products say "only use the official adapter that comes with the product".

      By adding the voltage regulator to our circuit, we are avoiding all this nonsense. Hope this helps.

      Delete
  7. Thx for this post. Ive done the bread board part now im on to the soldering. As my first project im still unclear on how the real things components connect.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Dear Dave,
    this website will probably be one of the best things that happened to me so far this year! Amazing stuff.

    I noticed that the Breadboard isn't on the list of required parts, so I added it to my shopping list anyway. Is there anything else I should add apart that?

    ReplyDelete
    Replies
    1. Hi Omar. Welcome aboard! I think you should be good to go. If you want to make a permanent version later, check out this post http://www.notesandvolts.com/2014/07/fun-with-arduino-arduino-on-proto-board.html

      Delete
    2. I certainly will, thanks!

      Delete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Hi,
    after trying out the schematic on the video and the ones that my teacher gave me, I still not able to upload the program to the arduino breadboard. however, I was able to compile the program. Why is that so? Is it because there is an COM Port error? But I have tried all the COM Ports.

    ReplyDelete
    Replies
    1. Hi Ein. What is the exact error message you are getting?

      Delete
  12. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hi Mojojo. You can definitely do that. Just make sure that the Positive and Negative wires from your supply go to the correct places on the board and you are good to go!

      Delete
    2. oh thanks you were quick! i ended up reading carefully and saw it was on this page! thanks alot!

      Delete
  13. I had some problem I dont know what it is but Im using L7805 and I think its him maybe some other ideas?

    ReplyDelete
    Replies
    1. also I have 100uf 35v capacitor

      Delete
    2. L7805 indicates the voltage of the regulator - 780?
      L7803=3v, 7808=8v, 7805=5v

      Delete
  14. This is a great site! My circuit actually worked first time. The breadboard PCB is great for the novice! Thank you so much for your time!

    ReplyDelete
    Replies
    1. Thanks Ben! It's nice to hear when things work out.

      Delete
    2. Dave, something odd is occurring. When I place a small rocker switch (for on/off)on my bread board version of the circuit the 9v begins to over heat. Any idea where I went wrong?

      Delete
    3. Hi Ben. It sounds like the switch is causing a short circuit between 9v and ground. Make sure that is not happening.

      Delete
    4. Ive tried a few different types of switches with the same results. In the off position the battery heats up quickly. I guess I will create the circuit with all new parts. Something must else be failing.

      Delete
    5. OMG novice moment, I think I got it. I had the switches leads inline with the diode. Once I moved the positive batery lead and the negative switch lead connection to a different area everything seems fine.... wow thx for your patience....and yikes.... lol

      Delete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Does it make any difference if I use the "AT49S 20PF DIP" crystal oscillator, or will any 16 Mhz crystal oscillator work just as well?

    ReplyDelete
    Replies
    1. Hi Chris. Most 16Mhz crystals should work.

      Delete
  17. Is this project open source?

    ReplyDelete
  18. Hi Dave

    I think your site is the best!!!!!

    I purchased the suggested power supply (9vdc/500ma) for the Arduino on a breadboard project. I discovered that the newly purchased power supply is unregulated and the VDC output is 12-14 volts. Is there a way to bring the VDC down without buying a another way-wart?


    Jesus Santiago

    ReplyDelete
    Replies
    1. My power supply is also unregulated, and pushes 13-14 volts. It's fine though, as the power runs through the 7805 regulator before hitting the rest of the circuit, and the 7805 can take up to 35 volts on input.

      Delete
  19. I've used the schematic here and have built one of these synths, and everything worked out great! Two things I need to point out though:

    If, like me, you don't want or need the pentatonic sweep knob, you can't just leave it out. You need to either ground it or disable it in the code.

    Also, the ISP header is displayed upside-down on the schematic above. I didn't realize that until I had it completely soldered in on my board.

    ReplyDelete
  20. you didn't list the 10K resistor in the shopping list... can the 220 ohm take its place?

    ReplyDelete
  21. I got this error while using arduino as isp.

    Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Uno"

    avrdude: stk500_getsync(): not in sync: resp=0x00


    please help me dave regarding this.

    ReplyDelete
    Replies
    1. Hi Jaldeep. This error can have many causes. Check out this link for some solutions

      http://www.instructables.com/id/A-solution-to-avrdude-stk500getsync-not-in-syn/

      Delete
  22. Hello. I am in the process of building this project in order to create the AUDUINO synth. However, I have access to a 5v 170mAh power supply, and would like to use this in place of the 9v wall wart. I'm no electronics prodigy, and I'm not quite sure what parts from your schematic I can do without. I know I can get rid of the rectifier diode and MOSFET, but do I still need either of the two e-caps, or both?

    Insight would be much appreciated. Thanks,
    ~STE

    ReplyDelete
  23. hi. im actually trying to make my own arduino board. If i refer to your schematic diagram and add headers to the rest of this I/O pins in atmega328p...is it possible to run all the programs just like an ordinary arduino board???

    ReplyDelete
  24. Is it possible that this circuit on breadboard can run ultrasonic sensor and Bluetooth module as an Arduino UNO? Thanks

    ReplyDelete
  25. Hi, will it work with 15Mhz crystal?

    ReplyDelete
  26. Hello Dave,
    Is possible to build full MIDI controller with buttons and pots (like another your project in parts 1,2,3) based on this ATMEGA328P circuit? I would like to reduce costs for Arduino kit.

    Kind Regards
    Beardini

    ReplyDelete
  27. Hi Dave,
    Thanks for sharing this info.
    Really helpful.

    Do you know how many ATMEGA328P microcontrollers you can power with this circuit?

    My design has 17 MCUs, so it would be great if I could power them all with one circuit, but that's probably not going to work.

    Thanks.

    Mike

    ReplyDelete
  28. Hi Dave,

    great video. Straight forward and clear!

    ReplyDelete
  29. HELP! I love the video, but when I plug the LED into pin 12 (due to our code) and nothing happens! It should be blinking just like in your video, but nothing. Any reason why?

    ReplyDelete
  30. how did you load the blink programe onto the chip before placing it on the breadoad? did you take the atmega out of the Arduino and place in the new chip ect?

    ReplyDelete
  31. After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

    Drjfitnessanimation.com
    Information
    Click Here

    ReplyDelete
  32. I love seeing blog that understand the value of providing a quality resource for free. 789 กีฬา

    ReplyDelete