I’ve been tinkering with Arduino boards for many years and I always find myself wanting something more; something flexible in terms of my prototyping needs. I decided to build my very own Arduino using a breadboard and components; this allowed me to prototype my projects before taking the decision to embed them and develop a custom PCB design.
Parts
For this example, I used the Atmel™ ATmega328P AVR™ integrated chip; you can, of course, use other Atmel ICs with any DIP package configuration for use with a standard breadboard, such as ATmega® 8/168. Below is list of parts that are required to build the Arduino breadboard:
For your reference, I have provided a schematic using Digi-Key Scheme-it, where you can also find the bill of materials used.
Adding Power to Your Circuit
First and foremost, you need to power your circuit. The best way to do this is using a standard 9V PP3 battery with a barrel jack adaptor as show in the below image or with a 9-12V DC power supply.
Figure 1: 9V Battery with barrel jack adaptor
Unfortunately, the ATmega328P IC does not take any other voltage input than 5V, this means we need to use a 7805 5V power regulator. This regulator is a TO-220 package where the input power supply is provided on pin 1 (left leg), ground is pin 2 (middle leg) and finally the 5V output is provided on pin 3 (right leg). This particular regulator allows you to input a varying voltage between 7-16V which is ideal for 9V batteries.
Insert the 5V regulator into the bottom of the breadboard, taking note of the orientation of the first pin.
Add power output and ground wires from the regulator to the power rails on the breadboard.
Insert a 100µF capacitor between pin 1 (input) and pin 2 (ground) on the regulator. If the capacitor is polarized, which means it will only work if connected to a circuit one way, the polarization can be determined by a small silver strip down the side of the capacitor which indicates ground.
Figure 2: Voltage regulator circuit
Insert a red LED into the breadboard power rails on the opposite side to the regulator, in series with a 220ohm resistor. This LED will give you an indication if power is reaching the ATmega IC and ultimately an output from the 7805.
Figure 3: LED connected in series to the breadboard power rail
To make sure that both sides of the breadboard’s power rails are connected you must insert two jumper wires between the positive and negative rails (figure 4).
Figure 4: Connected the breadboards power rails in circuit
Take the DC socket with screw terminals and screw in two jumper wires. Connect the positive jumper wire to pin 1 (input) on the regulator and the negative jumper wire to pin 2 (ground) on the regulator. This method allows you to easily unplug and swap the battery, if necessary, without unplugging all the jumper wires.
Figure 5: Connecting a screw terminal DC socket to the regulator
Finally, test the circuit by connecting your power source to the DC socket; you should see the red LED light up if successful (figure 6)
Figure 6: Power circuit connected
ATmega328 Circuit
Before you insert the ATmega328P IC, it would be wise to learn a little bit about what each of the pins do in relation to the Arduino functions. For further reading, please refer to the datasheet which can be found on the Digi-Key website.
Insert the ATmega328P IC into the breadboard, making sure that either side of the IC has bridged the small gap in the middle of the breadboard, as shown in figure 7. Note: Pin 1 of the chip can be identified by a small circle next to it on the silicone.
Figure 7: ATmega328P IC inserted into the breadboard
Now you need power to the ATmega IC so connect the following pins using jumper wires:
Pin 7 – Positive Voltage
Pin 8 – Ground
Pin 22 – Ground
Pin 21 – Positive Voltage
Pin 20 – Positive Voltage
Figure 8: Power connected to the ATmega IC
Add a 16MHz crystal between pins 9 and 10 on the ATmega IC; also connect a 22pF capacitor from each of the crystal’s pins to ground rail. A crystal is used to provide clock input to the microprocessor. Note: The crystal and ceramic capacitors are not polarized which mean it doesn’t matter which way you insert them into the circuit.
Figure 9: Crystal and 22pF capacitors inserted into the breadboard
Now add the momentary tactile switch to act as a reset button to restart the firmware. Insert the switch just above the ATmega IC making sure the two sets of pins are abridged; insert one jumper wire to the ground rail and to the first pin on the switch and the second jumper wire from the second pin below the first and into the row of pin 1 on the ATmega IC. Also insert a 10k resistor from the positive rail to the reset pin on the ATmega; refer to the schematic for reference.
Figure 10: Reset switch added to the circuit
Finally add a green LED to digital pin 13 on the ATmega IC, which you can use to upload an example sketch and blink the LED.
Figure 11: Green LED connected to pin 13
Bootloader
Before you upload any sketches to the ATmega IC first you must install something called a bootloader. A bootloader is a basic hexadecimal file that runs when you turn on the board. The bootloader is responsible for two things; first, it looks to see if a computer is trying to program it, if it is then it grabs that program and uploads it to the IC’s memory. Secondly, if nothing is trying to be uploaded then it runs the program which is already stored in the memory; this is why the program runs every time you switch on your Arduino.
There are a number of different ways in which we can install a bootloader to your ATmega IC, such as using a dedicated programming board such as SparkFun’s pocket AVR™ programmer (1568-1080-ND) or you can use an existing Arduino board.
In the following example I will be using the Digi-Key Metro board to install the bootloader and also to upload the first sketch example. There are four SPI pins which must be connected between the ATmega IC and the Metro board as shown in the table below:
Arduino as ISP
ATmega328P
MOSI/D11
MOSI/D11
MISO/D12
MISO/D12
SCK/D13
SCK/D13
D10
Reset
Go ahead and connect the Metro board to the Atmega328P IC on your breadboard.
Figure 12: Metro board connected to the ATmega
Plug in the power to your ATmega and then insert the USB cable from the Metro board to your computer.
First, we need to setup the Metro board to act as an in-serial programmer (ISP). Open up the Arduino IDE software and open up the “Arduino ISP” example sketch. Select the Metro board from the list of Arduino boards and click the upload button. Once completed the Metro board can now act as an ISP.
Figure 13: Arduino ISP sketch
To upload the bootloader, select the board settings for the board you want to program by navigating to Tools > Boards, which in our case is the ATmega328P IC. Select the option “Arduino Duemilanove or Diecimila”.
Figure 14: Select the board option for the ATmega328P
Select which processor of the ATmega IC you are using, Tools > Processor > 328.
Select the method of programming to the ATmega®, Tools > Programmer > Arduino as ISP
Figure 15: Selecting the Programming method
Finally, select Tools > Burn Bootloader and the process of installing the bootloader will begin.
Uploading Blink Example
Now that the bootloader is on the ATmega IC, it is waiting for a program to run. The process of uploading a sketch to the ATmega IC is simple.
Open the Blink example sketch in the Arduino IDE, File > Examples > 01 Basic > Blink
To upload the sketch through the Metro board, ensure that the settings are the same as when you uploaded the bootloader:
Board - Arduino Duemilanove or Diecimila
Processor – 328
Programmer – Arduino as ISP
To upload simple click, File > Upload using Programmer
Figure 16: Upload sketch using programmer in Arduino IDE
Once the sketch has been uploaded to the ATmega board, you can simply remove the Metro board and the jumper wires linking the two.