Introduction: Electronic Metronome
Please note that in this instructable I assume you have some experience with AVRs and the C programming language.
Step 1: Parts
- ATmega328p Microcontroller (Jameco #2139111)
- IC Socket (Jameco #112300)
- 150 Ohm Resistor (Jameco #690662)
- 10k Ohm Resistor (Jameco #691104)
- 0.1 uF Capacitor (Jameco #151116)
- Three Digit Seven Segment Display (Jameco #1956493)
- Red 5mm LED (Jameco #333973)
- Tactile Switch (3x) (Jameco #119011)
- Piezo Speaker (Jameco #1874543)
- ISP Header (Jameco #115035)
- 3xAA Battery Holder with Switch (Jameco #216144)
- AA Battery (3x)
- Velcro (Optional)
- Soldering Iron
- Wire Cutters
- Needle Nose Pliers
- AVR Programmer
Step 2: The Hardware
The hardware set up for the metronome is pretty simple. Since I designed it as a kit, I tried to keep the number of parts to a minimum while still having all the features I wanted.
As you can see from the schematic, all the functions are separated by ports so programming is nice and simple. Control of anodes for each digit is handled by port C. These pins will control the multiplexing of the display. Port D will control the cathodes of the display, essentially setting what segments of each digit to light up. And lastly, our generic I/O, things like the LED, speaker, and buttons, is handled by port B. The remaining connections are standard for operating the ATmega; like the 10k Ohm resistor on the reset pin and the decoupling capacitor between Vcc and ground.
Be sure to check out the third image above to see pin locations of the seven segment display. They can be a little tricky to figure out. Also, in the schematic the pins of the display block match the real world layout, so pin 1 is in the lower left corner and twelve is directly above it.
Step 3: The Software
In the interest if space, and for readers not particularly interested in the software that runs this, I have decided to forgo explaining the code here, and instead thoroughly commented it. The code is available for download below. I think it's actually better to look at it this way as the seeing the comments and the complete code together will make more sense then me trying to explain small snippets here anyway.
Also, I have provided two images from the Seven Segment Display's datasheet that should help you in better understanding that aspect of the code.
For details on how to upload your code to the microcontroller, see you your AVR programmer's manual; or if you're using Adafruit's USBtinyISP see their detailed tutorial here: http://www.ladyada.net/learn/avr/avrdude.html
Step 4: PCB Design
The board was designed with size in mind. I wanted to keep it as small as possible while still having all the components laid out in an easy to use way. I decided to make the width of the board match that of the height of the battery holder since I knew I would like to attach the two together. The results came out as follows.
I've attached the Eagle files for this project below for you to download. I used ITeadStudios to make the boards and I was really happy with the way they came out.
Step 5: Assembly
There are a few parts that you need to be careful with, especially of you're fairly new to electronics.
- Make sure that when you're installing the IC socket and the ATmega you matches the notches with the notch outline on the PCB. If you don't, the proper pins won't connect to else where on the board and you're metronome will not work.
- The only component that is polarized here is the LED. Make sure that you put the shorter lead of the LED in the whole closest to the outside edge of the board matching the flat edge of the epoxy case to the flat marking on the PCB.
- It does not matter which directions your speakers leads are.
- When connecting the battery holder, be sure that he red lead goes in the hole marked V+ and the black lead goes in the hole marked ground.
- When inserting the ATmega, you may need to bend the pins so they are perpendicular to the IC's body. To do this safely, lay the ATmega on it's side on a flat surface and use your index fingers on the underside of the body and your thumbs on the top as seen in the photo. Then rock the chip forward to bend all the pins on that side evenly. Do this to both sides.
Step 6: Use and Enjoy
After I put the batteries in the holder I attached a piece of velcro the holder and the back of the PCB so that I could attach the two together.
And there you have it, a simple yet functional electronic metronome.Thanks for reading!
TuchicoF made it!
We have a be nice policy.
Please be positive and constructive.