arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.14k stars 7.01k forks source link

Revised version of "Building an Arduino on a Breadboard" page #6484

Closed per1234 closed 2 years ago

per1234 commented 7 years ago

Proposed revisions to https://www.arduino.cc/en/Main/Standalone

The revised version is attached in the file (actually .md but GitHub doesn't allow attachments of that filetype): breadboard_revised.txt To allow a diff, the original version is attached in the file: breadboard_original.txt

Additional issue not solved in the attached file:

The image that should be shown to the left of "Before moving on, check out this image." in the "ATMEGA8/168/328 Basics" section does not appear. When I load the image link: http://arduino.cc/en/uploads/Hacking/Atmega168PinMap2.png it redirects to: https://www.arduino.cc/en/uploads/Hacking/Atmega168PinMap2.png so maybe that's the cause of the problem.

per1234 commented 7 years ago

Here's the text of the revised version in case anyone wants to review it without downloading the files:


Building an Arduino on a Breadboard

Overview

This tutorial shows you how to build an Arduino compatible breadboard with an Atmel ATmega8/168/328P AVR microcontroller and FTDI FT232 breakout board.

Originally created David A. Mellis Updated from the ITP version by Carlyn Maw Updated October 23, 2008 by Rory Nugent

Parts

To do this, you'll need:

Basic Parts for wiring up Arduino

USB to Serial Communication Board

You will need a FT232 USB Breakout board, such as:

If you plan to use the first option and have not yet soldered headers to the breakout board, now would be a good time.

Bootloading your ATmega Chips

There are several options for bootloading your ATmega chips, a few of which are covered in this tutorial. If you wish to bootload your ATmega chips using your breadboard, an additional part will make your life much easier but is not necessary: Adafruit 6-pin AVR ISP Breadboard Adapter

Adding circuitry for a power supply

If you've previously worked with microcontrollers, it is likely that you already have a preferred way to wire up a power supply to your board, so go ahead and do it that way. In case you need some reminders, here are some pictures of one way to go about it (This version uses a 5 V regulated power supply)

Add power and ground wires for where your voltage regulator will be.

Add power and ground wires at the bottom of your board connecting each rail.

Add the 7805 power regulator and the lines to power the board. The regulator is a TO-220 package where the input from the external power supply goes on the left, ground is in the middle and the 5 V output is on the right (when facing the front of the regulator). Add power OUT and ground wires that connect to the right and left rails of the breadboard.

Also, add a 10 uF capacitor between the IN of the regulator and the ground as well as a 10 uF capacitor on the right rail between power and ground. The silver strip on the capacitor signifies the ground leg.

Add an LED and a 220 ohm resistor on the left side of your board across from the voltage regulator. An LED attached to power like this is a great troubleshooting trick. You'll always know when your board is being powered as well as quickly know if your board is being shorted.

The red and black wires to the left of the voltage regulator is where your power supply will be plugged in. The red wire is for the POWER and the black wire is for the GROUND. Be sure to only attach a power supply that is between 7-16 V. Any lower and you won't get 5 V out of your regulator. Any higher and your regulator may be damaged. A 9 V battery, 9 V DC power supply, or 12 V DC power supply is suitable.

Now that the power-basics are done you are ready to load on the chip!

ATmega8/168/328P Basics

Before moving on, check out this image. It's a great resource for learning what each of the pins on your ATmega chip do in relation to the Arduino's functions. This will clarify a lot of confusion behind why you hook up certain pins the way you do. For even more detailed information, take a peek at the datasheet for the ATmega168 (short version) (long version). Here's the sheet for the ATmega328P (short version) (long version)

Start by connecting a 10k ohm pull-up resistor to +5 V from the RESET pin in order to prevent the chip from resetting itself during normal operation. The RESET pin reboots the chip when pulled down to ground. In later steps we will show you how to add a reset switch that takes advantage of this.

Note that, although not shown in the images, it is recommended to add a 0.1 uF capacitor between Vcc and GND and between AVcc and GND. Failure to do this may result in unreliable operation of your Arduino on a breadboard.

Add a 16 MHz external clock between pin 9 and 10. Add two 22 pF capacitors running to ground from each of those pins.

Add the small tactile switch so that you can reset the Arduino whenever you like and prepare the chip for uploading a new program. A quick momentary press of this switch will reset the chip when needed. Add the switch just above the top of the ATmega chip crossing the gap in the breadboard. Then, add a wire from the bottom left leg of the switch to the RESET pin of the ATmega chip and a wire from the top left leg of the switch to ground.

If you already have an Arduino board running, it is a good idea to go ahead and check the breadboard version you are building with a chip you know works. Upload 'File > Examples > 01.Basics > Blink' to your Arduino, pull the chip from your working Arduino, and try it on this board. The Blink sketch blinks pin 13. Pin 13 on the Arduino is NOT the physical pin 13 on the ATmega8/ATmega168/ATmega328P. It is actually physical pin 19 on the ATmega chip.

Refer to the pin mapping above to be sure you are plugging it in correctly.

Finally, add the LED. The long leg, or the anode, connects to the red wire and the short leg, or the cathode, connects to the 220 ohm resistor going to ground.

At this point if you had already programmed your chip somewhere else and didn't need this breadboard circuit to reprogram the chip, you could stop here. But part of the fun is in-circuit programming so keep going to really make a full USB-Arduino-circuit on a breadboard!

Arduino-Ready

Now we'll be adding the USB to Serial breakout board to our Arduino breadboard circuit. If you haven't added male headers to your breakout board, you will need to do it now.

Connect the VCCIO of the breakout board to power and the GND to ground.

Curious what all the pin outs are for the SparkFun FT232 breakout board, just simply flip it over! In this situation we'll be using VCC (to supply 5 V from the USB port to your board), GND, TXD, and RXD.

Now, it's time to get the USB to serial breakout board talking with your new Arduino setup. Connect the RX (pin 2) of your ATmega chip to the TX of the USB to serial board, and connect the TX (pin 3) of your ATmega chip to the RX of the USB to serial board.

Note that at the time this tutorial was written it was required to manually reset your Arduino board every time before uploading. Since that time we have discovered the amazing advancement of the auto-reset. With only one additional wire connected to the reset pin of the microcontroller from the USB to serial adapter via a 0.1 uF capacitor you can upload to your Arduino on a breadboard with a single click of the Upload button in the Arduino IDE! For details see http://www.gammon.com.au/breadboard.

And there you have it... ready to be plugged in, powered up and programmed!

But wait, there's another step right? If you pulled your ATmega chip out of your Arduino, it has most likely been programmed several times by yourself and so it definitely has been bootloaded, so you won't need to move any further in this tutorial.

However, if you purchased some extra ATmega328P or ATmega168 chips from an online store they will have NOT been bootloaded with the Arduino bootloader (unless the seller specifically noted that they have the bootloader). What does this mean? You won't be able to program your chips using the USB to serial breakout board and the Arduino software. So, in order to make your new chips useful for Arduino you MUST bootload them and MUST check out step 4.

Other Breadboard Options

The uDuino Setup by Tymn Twillman

This configuration is similar to the one above but the trick is that the ATmega chip is bootloaded with the Arduino Lilypad bootloader. The Lilypad runs using the internal clock instead of an external clock and so removes the need for much of the supporting circuitry.

Boarduino by Ladyada

The Boarduino is a kit you purchase and assemble to create a nice, small breadboard compatible Arduino set up. All the common components are included on a small PCB so that the Boarduino can easily be added to a breadboard and even removed, in a snap.

Bootloading your chips OPTIONAL

Bootloading Options

There are two options for bootloading your chips. The first being quite easy and the other being a little more tricky. We will cover both.

There are also many different kinds of AVR programmers. Here are some of the most commonly used ones:

Using an Arduino board

The non-SMD version of the Arduino Uno has a socket for the ATmega328P microcontroller. You can remove that microcontroller and replace it with an ATmega8/168/328P to use the board as a programming adapter. Place your ATmega chip into the Arduino board with the divot of the chip facing to the end of the board away from the USB jack. Then attach the 6-pin female plug of your AVR programmer to the 6 male header ICSP pins with the plastic nub of the ribbon cable head facing inward.

Using your breadboard

When bootloading an ATmega chip on a breadboard, Adafruit 6-pin AVR ISP Breadboard Adapter is incredibly handy. This adapter breaks out the 6 pins from the programmer for easy attachment to the breadboard. All the pins are also labeled making it very easy to connect it up to your chip.

Don't worry, if you don't have an AVR programming adapter you can still bootload without it. IThe two images to the left are great references when hooking up a programmer to an ATmega chip without an adapter board. The images will tell you what all the holes in the 6-pin AVR plug are and you will simply need to stick wires in the end and connect them to your ATmega chip.

This image is a view from the bottom and labels each of the holes. Take note of the square as to what orientation your cable is in.

Let's begin!

With the breadboard you prepared above, add two wires for power and ground for your AVR programmer.

Now plug the AVR ISP Breadboard Adapter into the breadboard with the GND pin matching up with the ground wire you just ran and the VCC pin matching up with the power wire you just ran.

In this step you will need to add the last four wires needed by the AVR programmer for proper bootloading. Be sure to refer to the Arduino pin mapping for help wiring this up.

Almost there! Just plug in a USB cable to your USB breakout board and plug the 6-pin plug of your AVR programmer to your AVR programming adapter. The black nub of the 6-pin head must be facing upwards towards the ATmega chip. In the next step, we'll show you how to use the Arduino IDE to burn your bootloader!

Time to burn!

Fire up the Arduino IDE and then go to 'Tools > Board'. Choosing the type of board you'd like to use will affect which bootloader will be put on your chip. Use Arduino/Genuino Uno for ATmega328P, Arduino Nano for ATmega168, or 'Arduino NG or older' with 'Tools > Processor > ATmega8' for ATmega8. Make sure to always chose that same board selection after burning the bootloader to your microcontroller.

Next, go to 'Tools > Programmer' and choose the programmer you will be using.

Then, click 'Tools > Burn Bootloader'.

The AVR programmer will begin bootloading your ATmega chip and a message will appear in the status bar which reads "Burning bootloader to I/O Board (this may take a minute)..." Lights may flicker on your programmer.

When done bootloading, the status bar will be updated with the message "Done burning bootloader." Your chip is now ready to be programmer using the Arduino software. Congrats! Power cycle your Arduino and your new ATmega chip will be running a simple LED blink program with Arduino pin 13 (if this is not the case, try programming it with one). If this is working, it was most definitely a success.

per1234 commented 2 years ago

It seems this tutorial has been completely removed from Arduino's website so I'll close this as resolved.

For future reference, here is the archived copy on the archive.org Wayback Machine:

https://web.archive.org/web/20220201170335/https://www.arduino.cc/en/Main/Standalone