Building a standalone Arduino from scratch and programming it with ICSP

We thought this might be a good topic for the site as it’s something we have done recently, this article will explain how to set up your standalone Arduino project on a breadboard. This will also include uploading your program code via the ICSP connections. This isn’t technically “an Arduino” as we will be not including some components, such as a USB connection, reset switch or any on-board LEDs.

The end result will be a breadboard and your Arduino project running on it, without an actual Arduino board.

What we’ll be using for this:

  • A USBasp AVR Programmer / or an Arduino for ICSP programming.
  • Breadboard
  • 10k Ohm Resistor
  • 2x 22 pF Capacitors
  • 16 MHz Clock Crystal
  • 5v Power Supply – We’ve using a breadboard power supply (3.3v and 5.5v)
  • An Atmel ATMega chip. We’re using an ATMega168
  • Wire or Wire Jumpers.

The first thing that you need to do is place the components in the breadboard; you can see on the schematic/board layout below where they should be going and connected to what.

Arduino

Pin 1 should have the 10k ohm resistor connected to +5v – This pulls up the reset so that it doesn’t reset; a tactile push button could be used here to implement resetting the program, the program will reset once this pin is pulled down to GROUND.

Pin 8 and Pin 22 should both be connected to the Ground Rail (GND) and Pin 7 and Pin 20 connected to the 5v Rail.

Pin 9 and Pin 10 should have the 16 MHz external clock and two 22 pF capacitors running to ground from each of those pins (see above)

ardpowerYou will now need your 5V power supply; we have a very cheap one we ordered off of eBay that cost around £1.20 at the time, it seems to work well enough for a breadboard project – which is in the photo on the right hand side. Connect up your +5V and GND to the breadboard rails.

Technically, that’s all that would be needed if you’re not planning on changing your code very often, as the above is a working “Arduino” and is ready to run code.

It’s built, now what?

For this article though we’re going to connect and upload our program code using ICSP. The ATmega chips all come with ICSP functionality and use the following pins (RST, VCC, GND, MOSI, MISO and SCK)

For this article we will be uploading your code directly onto the ATMega chip without burning a bootloader; this has the following benefits:

  • No 5 second delay when booting.
  • 1k of space is freed up for use by your program.
  • No need for a USB connection as we can program it via the ICSP headers.

We will be using an USBasp ICSP programmer to upload code on to the ATMega chip, again this is a very cheap product (around £2.50 off of eBay again) and it well worth having if you’re going to be doing a few of these. You can actually use an Arduino if you already have one, see the Setting up the Arduino as an ICSP Programmer on the Arduino.cc website for more information on that.

Take out your USBasp ICSP programmer, you should have a 10 PIN connection cable from it – We have made a quick “cheat sheet” below to remember which pins are connected to what, please do check that you are using the correct pins on your version of the USBasp as you could damage the chip otherwise. Our version is posted below:

icsphsAs you can see from ours it’s pretty straightforward. Each of the Pins listed above correspond to Pins on the ATMega chip. Make sure to connect up all 6 Pins (NC = Not Connected) and all of the GND pins are linked. Make sure to connect up both GND Pins and both VCC pins on the ATMega chip.

We have made the image below showing which Pins need to be connected to the USBasp for this stage. Note that this is for an ATMega328, however the Pin layouts are exactly the same.

atmega328

 

When connecting the chip up to the USBasp, DISCONNECT THE EXTERNAL 5V POWER that you connected previously; not doing so may damage your Chip, USB Port or USBasp Programmer and would severely sadden your day.

From this stage you should be able to go directly into the Arduino IDE; Select the correct Board from the Tools > Board menu, we chose the ATMega168 Arduino Diecimila / Duemilanove board.

Select the Tools menu again and choose Programmer > USBasp. You should now be able to use File > Upload Using Programmer to upload code to your chip; if you decide that you no longer want to use ICSP or want to connect up a USB interface to your project, you can also use the Arduino IDE for burning a Bootloader on to the chip (just like your official Arduino has).

You can now upload your project code and disconnect the USBasp and put back your 5V supply to the board; the end result should be a breadboard and chip running your Arduino project. You can add the optional reset button and LEDs if you wish, we didn’t include them in this article as they’re not required to make it work.

IMG_20140224_163218     ardbb

The photo on the left is a couple of days before we got our wire kit; it looks much cleaner on the photo on the right

You can see on the photo above that we have the breadboard and ATMega chip connected up with some jumper wires and have the USBasp plugged in next to it; we also hooked up an LED and Resistor to Pin 1 to test out the “Blink Example” from the Arduino IDE.

Hopefully after following this you should have something similar set up; let us know if you’ve done anything with this.

Have fun!

 

Email this to someoneShare on Google+Pin on PinterestTweet about this on TwitterShare on RedditShare on Facebook

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">