Every year, one of my favorite websites (Imgur) hosts a website-wide secret santa with thousands of participants. I’ve participated in it for the past couple of years, but I never did anything more exciting than just ordering something of Amazon and getting it drop shipped to my secret santa’s house. This year, I decided to create something a bit more personal.
Needless to say, I posted this on Imgur so I could get my sweet, sweet internet points. Click here to see the original post.
I figured it was within my skills to design and build a banana shaped clock emblazoned with the Imgur logo for my secret santa. I used an AVR ATMega328p as the brains, a DS3231 to keep time, and various other support circuitry to directly drive some bright yellow 7 segment LEDs.
Designing the Schematic
I wanted to design the circuit to be fool proof, something that I could design and print on a board that would just work. I figured skipping the breadboarding and prototyping steps would buy me some time. In the end, this actually ended up costing me the most time. Despite designing a circuit that I was 100% sure would work, I ended up making dumb mistakes and having to order three revisions of the board.
This is a mistake I will not make again
In the end, the circuit ended up being a little overkill. I used four different BCD to 7 Segment Display drivers to drive all the digits, one for each of the numbers on the clock, I could have gotten away with using just one to drive all of the digits if I really wanted to. If I was really clever, I also could have matrixed the all the LEDs. I also elected to use logic level converters for the DS3231, despite it being 5 volt tolerant. The typical operating voltage was 3.3 volts, and it was worth the extra couple cents in parts to buy myself peace of mind. After all, I was only going to be building a few of these.
Designing the Board
Early revisions of the board did not have a programming header, they just had test points for me to solder wires to that would plug in to my in circuit programmer. This led to me ripping the traces off of the board, so later revisions had a programming header. The hardest part was trying to fit all the components and traces onto such a strange board shape. I didn’t want to clutter up the front of the clock with too many components, so I tried to fit as many components as I could onto the back. This made it a nightmare to route all of my connections cleanly, as many of them had to go across the entire board.
I ordered all the boards from my new favorite board house, Elecrow. They always deliver great boards for me in a timely manner for a very low price.
Soldering this project together cemented my decision to invest in building a reflow oven (check back later for that build).
First things first, I wanted to solder on the microcontroller, programming header, and its various support circuitry. The build would continue when I determined the microcontroller could survive and function on my board.
I uploaded the classic Blink program to the board and looked for a square wave on one of the pins. The yellow line means it’s working!
I went digit by digit and made sure each one worked and responded to the microcontroller before I installed the next one. That way if I encounter a problem, I’ll know exactly which digit is having the issue.
Once all the LED driver circuitry was installed and tested, the next order of business was moving on to the DS3231.
The DS3231 is what actually keeps time. It has a super accurate, temperature compensated oscillator which is way more accurate than the oscillator that drives the microcontroller. If I didn’t use this chip, the clock would probably be off about 5 minutes every month.Whenever the microcontroller wants to know what time it is, it asks the DS3231 using a 2 wire serial protocol called I2C. Once the microcontroller gets the time, it writes it to the digits.
After programming everything, this is what the final product looks like. I’m really happy with the way this turned out, in fact I’m probably going to refine the clock design and sell custom clocks on Etsy or eBay or something.Feel free to take my designs and code and use it in your own projects. A credit or shoutout would be nice, but I don’t require it. All the designs are up on GitHub at this link: