loading

This is the first part of our BaW-Bot (Bells-and-Whistles Bot) build – 5 separate instructables that look into different Arduino-related technologies, combining to create a Bot with all the bells-and-whistles.

Part 1: Build an Arduino on a Board
Part 2: Build the motor-controller & body
Part 3: Adding Sight and Touch
Part 4: Blinging up the BaW-Bot
Part 5: Taking it to the Next Level

In this instructable, we’ll be building an Arduino on a Breadboard – this will form the base of the Bells-and-Whistles Bot series of Instructables, serving as the main controller through the next 4 instructables.


Why build an Arduino on a Board?
There are a number of reasons:
- Everyone loves a challenge – this is a fairly simple one, but a challenge none-the-less
- The cost is lower, so you don’t need to buy additional Arduino boards if you need them for your projects
- You have improved flexibility in terms of the form and shape that the controller takes.
- You can take it to the next level, and use stripboards or create custom PCB’s for projects that you want to make permanent

Update: Attached is a refreshed schematic in pdf and Eagle CAD.

If this instructable helped you, please visit Crash Bang Prototyping, follow us on twitter, and join in with other prototyping resources and tools.

Step 1: Parts

You'll need the following parts to get up and running. 

1 x Breadboard + jumper wires
1 x ATmega 328P microcontroller with Optiboot
1 x 16MHz crystal
2 x 10uF capacitors
1 x 0.1uF capacitor
2 x 22pF capacitors
1 x 220 Ohm resistors
2 x 10k Ohm resistors
2 x LED
1 x 5V voltage regulator
1 x FTDI Basic Breakout board
1 x 6-9V power supply and connector (or consider a DC Barrel Jack)

Arduino IDE installed on your PC

Step 2: Setup the Power Connections

The first step is to get an external power supply regulated to a constant 5V that the ATmega328 needs for stable operation.  You could also use a 3.3V supply, as the ATmega328 has a wide operating range.

Depending on the size of your project, you may choose to create this on a half-size or full-size breadboard.  To keep this compact, I haven’t put any diode protection in place – therefore make sure you connect your external power source correctly – don’t connect the +ve to the –ve!

Connect your external supply
Connect your power supply connector to the board.
Then add a 10uF decoupling capacitor across the supply pins. Note that these capacitors are polarised, so you’ll need to connect the side with the negative indicator (look for a stripe or -ve sign – or check your datasheet) to GND, and the other to +ve.

Connect the voltage regulator
Now add the regulator, ensuring that the external supply positive lead connects to the input , and the negative to the GND.  Again, check your datasheet carefully.
Connect the other 10uF capacitor to the GND and output from the regulator, and then take leads from the GND and output to the power rails of your breadboard.  This power is "clean" and will be at 5V.

Also add leads to connect the 2 power rails from your board so that they are both powered.

Add a power LED
Finally, let’s add a LED to show when the board is powered.  Connect a 10k resistor from the GND rail to the cathode of the LED (the shorter leg), and run a wire to connect the anode to the positive rail.  I’ve used a blue 3mm LED, and the 10k resistor so that it doesn’t burn too brightly.

Now you’re wired up and ready to add the processor.

Step 3: Add the Microcontroller

Gently insert the ATmega into the breadboard, so that it straddles the centre separator.  Place it so as to keep the board nice and compact.  If you prefer, you can use a ZIFF socket to allow for easy removal and re-insertion (I’ve bent more legs on these chips than I can remember!), but pay attention to how the pins in the socket line up with the breadboard pins.
For this example place the notch towards the power we’ve just connected – or the pin 1 dot at the left.

Once the chip in mounted, connect the power:
+ve rail --> VCC (pin 7)
+ve rail --> AVCC (pin 20)
+ve rail --> AREF (pin 21)
GND rail --> GND (pin 8)
GND rail --> GND (pin 22)

Step 4: Connect the Crystal and Reset

Crystal
Connect the 16MHz Crystal between pins 9 and 10.  This will regulate the speed of the ATmega.

You should also then add two 22pF capacitors between the crystal pins and GND.

Pull-Up Resistor on Reset
You now need to pull the reset pin up, using a 10k Ohm resistor.  You could add a reset button that would connect to GND, however I'm going to use the reset functionality of the FTDI board so won't clutter my board with one.
Add a 10k Ohm resistor between the +ve rail and the Reset pin (pin 1)


At this stage you’ve got the basics of the board setup.  It would now function, however there is no easy way to programme it.  I’d also like to add a LED on pin 13, like the “real” Arduino.

Step 5: Connect the FTDI Board

The FTDI board acts as a USB-to-Serial converter with a few extra touches that allow you to upload sketches.  You could also use the breakout to power your project if you don't have an external supply, or while testing your project.

Connect the Reset
The FTDI board sends a reset signal to the chip, to activate the bootloader in preparation for receiving the sketch being uploaded.  Connect the DTR pin of the FTDI, via a 0.1uF capacitor to pin1 on the ATmega.

Connect the Transmit & Receive
Next the FTDI needs to communicate with the ATmega – use the Tx and Rx connections for this.  You need to connect the FTDI’s Tx to the ATmega’s Rx, and in the same way the Rx to the Tx.  (The one needs to receive the others’ transmissions – the two Tx pins can’t talk to each other!)

- Connect the TXO of the FTDI to the RXD on the ATmega (pin 2)
- Connect the RXI of the FTDI to the TXD on the ATmega (pin 3)

Connect Power
You can, if you choose, connect the power from the FTDI, so your project is powered from the USB port:

- Connect the 3v3 to the +ve power rail (my FTDI outputs 5V – pin is incorrectly marked 3V3)
- Connect the GND to the GND power rail


Now you’re one step closer – you can upload sketches using Arduino IDE (select the UNO, as the chip has been pre-loaded with the UNO Optiboot Bootloader)

Step 6: Connect the Pin 13 LED

Finally, let’s add the LED we find on pin 13 of the Arduino Uno. This is a useful LED to have on-board for trouble-shooting or as an indicator. We’ll also use it now to test that the board is working correctly.

Connect the LED
Place the LED on the board, then connect a 220 Ohm resistor from GND to the LED’s cathode.
Add a jumper wire from the LED anode, to pin 19 on the ATmega.

Important note: the physical pin numbers on the microprocessor are not the same as the (logical) pin numbers you refer to in your sketches. Physical pin 19 maps to logical pin 13. Refer to the image below.

Test the Board
It’s time for the blink sketch! Double-check your connections, then connect the FTDI board to your PC with a USB cable. For this example, connect the power jumpers from the FTDI to your breadboard first.
- You should notice a new COM port available (under the Tools – Serial Port menu). Select this.
- Under Tools – Board, choose the appropriate board to match your bootloader (most likely an Uno)
- Then load the Blink sketch and upload it.

The LED should flash a few times, and then the Tx and Rx lights on the FTDI should flash back-and-forth as the sketch is uploaded.

Once the sketch has been loaded, you should see the comforting slow flash of the LED.

Oh No - the sketch doesn't upload!

Are you sure that your microcontroller comes with a bootloader. If it doesn't, don't panic - there is a way to burn a bootloader onto your chip.

Congratulations!

You're now ready to move onto Part 2 of the series, playing with motors to create a basic BaW-Bot.

<p>Do I need 2 22pf Capacitors or 2 2.2pf Capacitors?</p>
Hi<br><br>You need 2 X 22pf caps.<br><br>Cheers<br>Andrew
<p>Yes I've always wanted one of these. Time to scour the streets for electrical waste.</p>
<p>i have Atmega 16 can i use it instead of atmega 328P</p>
<p>If you plan doing something with the analog pins, you really want your power as clean as possible, especially if you have any kind of magnet around. Add a 100uF capacitor between 20 and 22 (VCC and GND), bind 20 and 21 (VCC and AREF), 20 and 7 (VCC), 8 and 22 (GND) together and put some inductor (10uH is fine) between +5V and 20, 21 or 7 (VCC/AREF). Also, the 328 can handle 20MHz (+25% with better clock accuracy on delay()) but the fuses are completely different (you didn't set the fuses, it's probably still running its internal clock at 8MHz, merely ignoring your quartz).</p>
Great thanks for the input. You are of course right. On the crystal I had burned the bootloader and set fuses so was using the crystal on that front - but probably not necessary to have that kind of accuracy for this project.
<p>Andy, thanks for this tutorial. Do you have to add something to programmers.txt? If not, what programmer do you select from Arduino IDE?</p>
<p>Hi Martin. You shouldn't need to change the programmers.txt or even select a programmer. As long as you have a bootloader on your microcontroller, the IDE uses the FTDI board to program the controller over serial.</p>
Andy, I find the solution this night. For me it is mandatory to select Arduino Duemilanove w/ATMega328 from Tools-&gt;Board in Arduino IDE <br> <br>Thank you <br> <br>PS: sorry for the new post instead of a reply, but with all my browsers, I can't reply to you for an error in display Captcha
Hi Andy, thank you for this tutorial. <br> <br>I try it and when I upload the sketch, breakout tx led flash for three times and then nothing, Arduino IDE fails with error: avrdude: stk500_recv(): programmer is not responding <br> <br>This happens even with 1K pullup on TX and RX. <br> <br>Any ideas? <br> <br>Thank you
Hi <br>I'm guessing this could be caused by any number of things - I haven't come across it in the past. It's tough to troubleshoot remotely, but suggest you look at: <br>- have you successfully used the breakout in the past? <br>- try unplugging the USB cable and plugging into a different port <br>- are you using the latest version of the Arduino IDE? <br>- are the breakout drivers installed correctly? <br>- does the breakout you're using have a DTR connected to the reset pin? Could be that the chip isn't resetting and starting the bootloader. <br> <br>Otherwise, try searching some of the forums (breakout manufacturer's as well). Please let us all know how you resolve?! <br> <br>Thanks <br>Andy
Do you have a circuit diagram for this??
Hi. Yes, there is a .pdf download in step 1 that you can download. Not really pretty, and I haven't had a chance to do one in EagleCAD yet. Hope it works. <br>Cheers
Ok
Thought you might like to know - finally gotten around to doing an EagleCAD schematic...
Ok, thanks for telling me.
Don't we need 1k resistors while connecting Rx and Tx pins of the FTDI to the pin 2 and 3 of the ATmega ?
I haven't needed one with any of my projects so far. There is one comment on the SparkFun site claiming that a 1K resistor helped to resolve communications issues but I haven't come across this problem. Did you need one?
no i also didnt need any 1k resistors. it worked nrmally :)
is there a circuit diagram at this?? tnx (^_^)
Hi <br>I tried to draw one up in Fritzing, but it was really unreadable - the image above was clearer. Sorry don't have one, but hope the steps talk you through it ok?
I need it too. Please.....
I've added a schematic of the board in the Intro / Step 1 - hope that this works for you. <br> <br>Cheers
Hi <br> <br>I can't see the cable properly from the image, but the cable would need to act as a USB-to-Serial converter. Is it like this one: <br>https://www.sparkfun.com/products/9718? <br>Sparkfun say that this allows you to programme an Arduino, but I haven't tested it personally. You'll also need to check the pin configuration matches that of the Breakout board... i'm not sure of the implications of using the RTS pin to reset the Arduino vs the DTR (breakout uses the DTR) <br> <br>I like the breakout board, as it's also got Tx and Rx lights so you can see that the sketch is uploading correctly. <br> <br>If you try it, please let me know how it goes!! <br> <br>Cheers
can i use a ftdi usb cable, like this? http://farm4.static.flickr.com/3393/3614832126_0378e5d27f.jpg
can i use a ftdi usb cable, like this? http://farm4.static.flickr.com/3393/3614832126_0378e5d27f.jpg
Nice job.

About This Instructable

44,398views

88favorites

License:

Bio: I’m not a rocket scientist. I don’t have a master’s degree in Electrical Engineering. I love automating, hacking, robotics, creating, building, understanding ... More »
More by AndyTallack:Bootload an ATmega328 BaW-Bot Part 3: Adding Sight and Touch to the Bot BaW-Bot Part 2: Build the motor-controller & body 
Add instructable to: