Tutorial: Shrinking your Arduino projects

Introduction

I got my first Arduino a couple of years ago but it wasn’t until recently that I tried making a standalone circuit with just the microcontroller. It sounded intimidating to me before I tried it but now I look forward to seeing my projects break away from the Uno board. There are many resources out there that can help you do the same, but I wanted to throw in my vote of confidence and show you the method that has worked well for me so far.

Requirements

Arduino Uno board

Yes, you’ll need one if you’re going to follow this tutorial. This tutorial is geared toward people who have already been playing with their Uno and want to shrink a project. The Uno will act as our programmer. You can program the chip directly using other methods but I can’t speak of them since I haven’t tried them.

Atmega328p Microcontroller

There are other Atmega chips out there so make sure you’re using this one if you’re going to follow the information here. Also, get one with a bootloader already on it. I purchased mine from Dipmicro which has the Optiboot bootloader on it already. You can get the other one with the Duemilanove bootloader, but make sure to select “Arduino Duemilanove w/ ATmega328” when you program using the Arduino IDE.

Breadboard

You can’t have too many breadboards. I’m sure you already have one sitting beside you right now.

Capacitors

We’ll need two 22pF (22) and one 100nF (104) capacitors.

Crystal Oscillator

We’ll need one 16Mhz crystal oscillator.

Resistors

We’ll need one 10Kohm resistor. We’re running the blink sketch so we’re going to need another resistor for the LED.

LEDs

One LED for the blink sketch. A power indicating LED is optional. Just remember the current limiting resistor!

(Optional) Voltage Regulator

The Atmega328p chip can handle 5v only. If your power supply gives you more than that, you’ll need a regulator to drop it down to 5v. Check out my LM317 tutorial for one solution.

(Optional) Push Button

If you want a reset button, you’ll need a push button. I personally don’t include them because all of my projects have an on/off switch that I could just toggle.

Connecting the Circuit

You can find the pinout of the Atmega328 chip from the datasheet. The chips that I get already have a label. There are places that sell the labels if the chips that you get don’t have them already. They’re great to have because there’s no use for a schematic. It’s really that simple.

IMG_0877

I don’t have a schematic to share but a quick search on Google will get you one. If you’re good at following text instructions, it’ll be easy:

1. RST has a 10Kohm resistor to 5v.

2. The 2 Vcc’s on both sides and REF go directly to 5v.

3. The 2 GND’s on both sides go directly to ground.

4. The 100nF capacitor connects Vcc and GND on the left side of the chip.

5. X1 and X2 go to ground using the 22pF capacitors.

6. The 16Mhz oscillator connects X1 and X2.

IMG_0869I don’t have any larger breadboards to show  you how to connect it up, but this small breadboard is a great example of how small you can get the controller to be.

Programming

Like I said earlier, we use the Arduino Uno board to program. Just remove the current chip, insert the one you bought for your shrunken project, and program as you normally do. It’s a good idea to unplug the board when you’re swapping chips. Once you get comfortable, you won’t even have to prototype on the Arduino Uno. You’ll start using it just for programming. There are other ways to program the chip directly but I haven’t tried them (yet). This way just seems the easiest considering I already had the Uno so I won’t need to buy anything more.

Conclusion

So yeah… There are guides out there that may be better to follow with more graphics. Once you do it once, you’ll never go back to sharing around your Uno between your projects. I just wanted to show off my method and encourage people to try it!

Advertisements

The Box: Prototyping

So “The Box” project is back, taking on a less ambitious form this time. I’m not going to try and cram every part I have into a box. It’s just going to be a simple temperature and humidity monitor with a clock and some LEDs. It’s nothing fancy, but I’m hoping I end up with a polished final product.IMG_0826I’ve begun prototyping all of the elements of the project together and I think I have a solid base right now. Let me walk through how the prototype currently works.

IMG_0831The system greets you when it’s first powered on. There is actually a reason for this which will be explained shortly.
IMG_0832This is the main screen. The clock can be toggled between 12 and 24 hour formats. The bottom line alternates between the temperature and humidity readings every three seconds.IMG_0835There’s the button to toggle the clock. The system is powered by a 9v power adapter into a 5v regulator. The brains is an Atmega328p microcontroller.IMG_0834Those two perfboards have the temperature/humidity sensor and the real time clock. Oh look, some LEDs!

The LEDs go back and forth signalling a complete second. It’s done using delays which provides a break for the LCD and sensor updating. While the LEDs are going back and forth, it isn’t actually using the RTC. It’s simply delayed so that a cycle back and forth takes a second.  This takes us to the reasoning for the power on screen with the “Hi”. What’s actually going on is there’s a delay so that you can always read the “Hi”, then it waits for the next second change by the RTC. This process syncs the start of the program with the start of a clock second. That way, every time the program loops back to the beginning, it starts at the top of a second since each loop of the program takes a second to complete.

Check out this video to see the prototype in action:

Random Arduino experiments

Right now, I have no Arduino projects planned. I’ve been trying to stay on track with school, but I find that the breaks I take are getting less productive. Even when I was in full-time school, I’d be doing electronics-related things (or web design projects) in my free time on the weekend. I’d really like to have at least something ready to go for Halloween but it doesn’t look like that will happen. I decided to play around and go with whatever comes to mind so here are a couple of things I did last night.

I bought the Arduino Mega so that I could make use of it’s 50+ pins. There are other ways to get more out of your Arduino, especially those with the Uno and others that have less pins. One way is to create an array and use a technique called multiplexing. The anodes can be connected together in rows while the cathodes are connected in columns. You can then “address” each LED by configuring the right row and column so that there is a potential difference across the LED (as in the anode is HIGH while the cathode is LOW/ground).  I learned this stuff in school using ICs and development platforms so it took me a while to wire it and get it going. I didn’t even bother to figure out how to program it but hopefully I understand the concept correctly again. I’ll stick to the Arduino Mega for any project that requires that many pins (usually my light shows), it’s just easier that way.

IMG_20131011_113747

The second experiment were a couple of drive tires. I’ve been inching to create a ride model but everything seems too complicated. I could go for a very simple swing ride, though. It’s just hard to get started. Anyways, here’s a gif of those drive tires…
1381513134584

That’s all I’ve got. Hopefully there’s something more interesting for the next post. Thanks for reading!