There's lots of LED clocks out there. There's lots of binary clocks out there. This is a mix of them both. On a single seven segment display, you can get to within about five minutes accuracy of what time of day it is.
My first cut at this was to use an Adafruit BLE Feather and update my cruddy RTC with a BLE message once a month. But I got a DS3231 instead and it's much better accuracy, so you can run this most any Arduino-ish thingy you have.
- Feather or Metro or Arduino. The choice is yours...the choice is yours.
- The DS3231 is good or go with DS1307. DS3231 is 3V happy.
- Ye olde 74HC595 for me.
- Pick a LED.
- Resistors - You'll need eight and still get the right mA through your LED. Do the math. A 100 ohm @ 3.3V with a red LED is usually fine.
- Trim pot - A trim pot can be used to choose which of the bit patterns you'd like to see.
- Switch - A single-pole single-throw switch to turn on/off daylight savings time (optional).
This sketch accomodates either common anode or common cathode LED. Just change one variable. The breadboard layout is simple but always tricky with so many wires. Here's the high level setup.
| Arduino Pin 12 -|- SRCLK 74HC595 Q0 -|- DP(5) LED (3 or 8) -+- 3.3V (common anode from Feather)
| 11 -|- RCLK Q1 -|- C(4)
| 10 -|- SER Q2 -|- B(6)
| A1 6 -|-+ Q3 -|- E(1)
+------+--------+++ \ Q4 -|- F(10)
| || \ Q5 -|- D(2)
trim pot DS3231 SPST Q6 -|- G(9)
Q7 -|- A(7)
The clock just goes on the I2C SDA/SCL lines. Pick any open port for your switch.
The Fritzing diagram shows the basic layout. Be sure to calculate the right resistor for your LED. The typical 74HC595 doesn't like lots of current through it so get the specs for your LED and use the right resistors.
You can also wire this directly if you have enough pinouts. My first draft was built that way and I simulated an RTC with a simple accumulator.
There are a few settings you should look at in the code. The first is the type of LED, common anode or cathode. Look at what display pattern you want to use. The bits can flip in a few different patterns, so pick the one you like. I like to keep the decimal point as either the "mid-quarter" blinker or as the high "16 o'clock" bit. It's also most aesthetically pleasing to keep the two quarter hour bits in some kind of harmony, either together or mirrored. Then it's up to you to choose how the hours will light. Some patterns have a great "finale" at the midnight switch. Others are easy to decipher at a quick glance.
This sketch requires few libraries, especially if you don't put the Arduino to sleep or use BLE.
- Wire.h - for communication between the Arduino and the RTC (probably)
- LowPower.h - for reducing power consumption (optional)
The final build will incorporate a few additions.
- BLE communication: get time from UART. Show the name of the current pattern and time.
- Dimmer: global PWM from a photosensor. (?)
- DST: Set your offsets settings, and you'll be set. (DONE)