I keep hearing smart watches, wearables, internet of things etc. which got me thinking about the hardware and embedded systems used to create them. As much as I love soldering and reading resister codes I’m ashamed to say the most complicated thing I’ve made was an FM transmitter.
Since I had an Arduino lying around I decided to build a watch to learn more about the hardware side of things. The plan was to build a POC clock using the Arduino and then shrink it to a watch using an ATtiny .
So I decided on 24 LEDs, 1 each for hours and minutes at 5 minute intervals. They could blink to show seconds ticking (stretch goal). Another (much cooler) idea was to use 4 LEDs to display the hours in binary… but then again, no way will I be able tell the time after a few beers
I’ve heard Arduino is not very good at keeping time accurately. So I wrote a quick sketch to test this. Fortunatly after a few hours of testing with this code, the Arduino seems to keep time reasonably well.
Now I have to individually control 24 LEDs using much lesser number of output pins from the Arduino. This was the hard bit, but few searches later the answer was to use a ‘serial to parallel converter’. Lucky I found this excellent post by DrLuke http://bildr.org/2011/08/74hc595-breakout-arduino/ on how to do this using a 74HC595. You can find a great explanation about each pin out there, but basically they have 3 pins. The clock/SRCLK (or stepper as I like to call it), the input/SER and the RCLK which is like a paint() or draw() function. Every time you give a pulse using the clock, the 74HC595 will take the value of the input pin and assign it to output pin 1 and cascade/shift down the value of pin 1 to pin 2 etc. Since the chip only have 8 outputs, I will need 3 of these.
So I opted for a PCB with pre drilled holes. First thing I did was place all 24 LED’s in two circles and soldered the cathodes or the negative pins together. As a software dev I KNOW to test at every step so I attached a crocodile clip to the negatives and tested each of the LEDs using a 3v battery pack for bad soldering joints and short circuits.
Now to the hardest part, solder the rest of the 24 LED positive pins to the 3 74HC595s.
Unfortunately it was after I soldered 48 LED pins and 48 pins of the three 74HC595s, I learnt about charlie plexing, which could avoided the three serial to parallel converters all together! Facepalm!
Seventy percent of all archaeology is done in the library.” -Indiana Jones.
I guess “Seventy percent of all electronics should be done in Google”.
Since I want to use the Arduino for other projects I replaced it with an ATTiny84 which was programmed using the Arduino, but that is post for another time. I used an IC socket for the ATTiny so I can remove it to reprogram it/set the time.
I had a issue with the ATTiny resetting when all 24 LED’s were lit at the same time to indicate seconds ticking. This was caused by a voltage drop due to high load. A 10μF capacitor between Vcc & GND fixed it.