Sunrise Alarm Clock
An alarm clock that turns on LEDs at a specific time. Replaces the hacky version of a timer on the standing lamp.
Power
From the wall I have 15V at 1 A, which can run the LEDs.
I will use one of the small buck modules to step that down to 5v for the logic. I can either give the board 5v via "5v" or 9v via "Vin".
I'd also like to put a large capacitor on the 15v input, if the power is cut, it should be able to keep everything running for a few seconds, maybe a few minutes.
LEDs
An individual LED is rated at 1W and 3-3.3V, so 1/3A.
At 15V, we'll have a current limiting resistor, 4 LEDs in series and then a control FET. The 4 LEDs will be at about 3.3V each, so 13.2V. Which means the resistor should drop 1.8V. At 1/3A, this means it should be about 6Ω. This also puts it at 0.6W, so use a few resistors in parallel.
I probably want at least 8 LEDs, so there will be two strips, but they can share the FET.
Buttons
5 buttons, 4 directional and one for light control.
That's 6 pins; 5 button pins and one shared interrupt.
I'm not sure I can really reduce this. At this size a matrix doesn't provide any gains. Shift out would still require 4 pins and add a lot of complexity.
I think I should do a voltage divider on an analog pin. This reduces the whole thing to two pins. Upstream of the resistors I'll use diodes to hook all buttons to an interrupt. Then the resistors will identify the button.
Controls
- Set the time
- Set the alarm by time and day
Nightlight function turns on the light at a low level.
Input will be buttons, output is an HD44780 display.
Logic
Most of the time the Arduino will be in sleep mode with one interrupt on the buttons and one on a timer.
The "nightlight" button will turn on the LEDs on a low level while it is held down, it gets brighter until released. It then stays at that level for one minute.
If the light is on (either from alarm or nightlight), "nightlight will turn off the LEDs".
Any of the control buttons will turn on the screen. Initially it displays the time. ↑ and ↓ scrolls through config options:
- Set Time
- Set Alarm
- Cancel/Uncancel Next Alarm
The ds3231 has a built in alarm, that stores the alarm and provides an interrupt signal.
DST
I don't think the DS3231 has DST built in. I can hard code DST dates for something like 20 years (much longer than I expect the clock to be in use).
Pins
- LCD: 7D, 4D with LiquidCrystal595
- LED: 1 PWM
- Buttons: 1A 1D
- DS3231 RTC: 2 A, 1 D
Build Plan
HD44780
Wire this up with some buttons, get a sort of "hello, world" working.
Done.
I will need 7 pins to drive this, one PWD to drive the backlight.
Once I get the control voltage on V0 dialed in, replace the pot with two resistors.
Look at LiquidCrystal595, it will free up 6 pins.
DS3231
Get this working so I can both set and read the time. Just output over serial. Buttons to control.
Requires getting a library.
Got basic setup working. Got the alarm working. Also reading the alarm.
Can I put a cap and diode in front of the power so it won't reset if the power is cut. If the diode drop is too much, I could just put a diode in front of the arduino too and increase the input power to 6v.
Buttons
Make a test set of buttons and wire them up.
LEDs
Drive a FET with the Arduino to control LED brightness. Will probably need to be BJT → FET.
Got the LEDs tested. They do run a bit hot, but I think they're ok for prototyping. When I do the real one, I can use a large copper board to dissipate heat. Or setup a heatsink.
Sleep
Test putting the Arduino to sleep and waking it up with both timer and input.
Prototype
Throw everything in a sterilite box, just to test it out for a few weeks. Use a full Duo.
Final
Put the controls on perfboard and make a box with a control panel.