Introduction: ChipKIT Alarm Clock
Have you ever wondered how to make your own alarm clock? Is it hard? Is it easy? I know from personal experience that making your own clock is definitely on the easy side and will show you how you can make your own today.
Step 1: What We Need
- 1 four digit-seven segment display
- 1 Speaker-buzzer
- 2 LEDs
- 7 220 Ohm resistors
- 6 Buttons
- Breadboard jumper wires
- A breadboard
- chipKIT Uno32
The speaker-buzzer that comes in the kit, an AC-1005G-RPA-LF, is not very loud, so you may want to invest in some sort of amplifier or louder speaker after making this circuit.
Step 2: Setting Up the Circuit- the 7 Segment Display
The seven segment display is going to be the heart and soul of our alarm clock; or at least I've heard rumors that clocks that don't actually tell you the time are quite useless.
Seven segment displays are designed where all of the individual segments are tied together between each of the digits. Thus, in order to be able to display different values on each of the digits we will have to cycle through each of the digits individually. To achieve persistence of vision so that it looks like all of the digits are displayed simultaneously, we will loop through our circuit very rapidly at 50 Hz or faster.
To setup the seven segment display itself, begin by setting it somewhere on the the breadboard with it's two rows of 6 pins straddling the valley. Then based on the schematic, wire each of the cathodes (pins 11, 10, 7, 5, 4, 3, 2, and 1 which represent each of the segments on a digit) to some of digital pins on the Uno32. As long as you avoid using the digital pins 0, 1, "G", or "A", you should not encounter any technical difficulties.
As for the anodes (pins 12, 9, 8, and 6), connect pins 9, 8, and 6 to some of the digital pins on the Uno32. For the first digit, A1, attach a 220 Ohm resistor to pin 12 on the seven segment. Then wire this pin to one of the digital pins on the Uno32. The reason that only the first digit has a current limiting resistor is for visual lighting purposes. Our particular clock is going to display an "A" or "P" for AM or PM, so in order to make the letters unobtrusive with the numbers, we need the resistor. Thankfully though, the only number that would ever be displayed in the first digit is a 1, which only takes up segments 'B' and 'C', so it will be appropriately bright when compared with the remaining three digits.
Step 3: Setting Up the Circuit- Buttons, Buttons, Buttons
Luckily for us, buttons are really straightforward to hook up to our circuit. But lets get some power to the breadboard first. Connect the 3.3V pin on the Uno32 to the power bus strip and connect a ground pin on the Uno32 to a negative bus strip. Then place the five buttons in a row, all straddling the valley. I would personally use a larger button on the far left as well as an additional larger button one spot from the right.
As for the connections, wire one of the legs on each of the buttons to the 3.3V power bus and connect a different leg on each of the buttons to the negative bus strip by using a 220 Ohm resistor. Then attach the grounded leg of each button to a digital pin on the Uno32.
It's ok if the buttons do not fit very securely into the breadboard, just as long as they are not jumping off of the breadboard. Yes, that has happened to me.
Step 4: Setting Up the Circuit- LED's and Speaker
We are now down to the final three components that we need on the breadboard; the two LED's and the speaker buzzer. Place the two LED's somewhere on the breadboard, preferably with their shorter cathodes in the same "node". Connect their cathodes to the negative bus strip and each of the longer individual anodes to their own digital pin on the Uno32 (don't worry, we won't run out of available pins).
And finally, place the speaker buzzer somewhere on the breadboard (you may have to move some of the other pieces around so that everything fits comfortably). Connect the pin that is further away from the speaker "mouth" to the negative bus strip and connect the pin that is closer to the speaker mouth to yet another digital pin.
Step 5: The Code
If you don't already have the free mpide software to compile the code onto the Uno32, you can download it from here.
I won't go into great detail on how the code (provided just after this step) interacts with the various components, but I do want to touch on a couple of things that I feel are key points into making this circuit work properly.
The first is to make sure that all of the digital pins are declared to be inputs or outputs as appropriate, otherwise you may find that your buttons do not work as they should if they are not labeled as inputs.
Additionally, because our circuit is generally running at 125 Hz, we need to make sure that the clock updates its display at the appropriate time. Right now, as per the code, the clock is changing its value once every second or when it cycles through its loop 125 times. If we instead wanted to have the clock update once every minute, the "min2" variable would need to increase when "tick" reached 7500. This is because 7500 cycles / (125 cycles per second, or Hz) = 60 seconds.
Step 6: Operation
I hope the code itself is pretty explanatory as to how the system works, but for those of you who are like me and would prefer a more visual explanation, check out my youtube video demonstration of this alarm clock.
To find out more about what Digilent is up to, check out the Digilent blog site and thank you for visiting my instructable!
We have a be nice policy.
Please be positive and constructive.