# Dawn Simulator (Prototype)

The body is made to wake up with the sunlight. I really hate getting up in the morning when it’s dark in my bedroom. Thats particulary bad in the winter when the sun rises after I should get up, but also in the summer, because I have very light tight curtains.
A dawn simulator is a light that gets slowly on in the morning to simulate a dawn and let the body wake up very smoothly.

There are many dawn simulators out there to buy, but I wanted to build one on my own for quite some time and now I did it.

# Schematic

To finally build one was a very spontanious decision, so I had to use parts I had at home for the first prototype.

#### Microcontroller

I had three µC laying around, one ATmega1284P, a ATtiny45 and an Arduino Pro Mini.
The ATmega1284P is one of the most powerful ATmegas out there, with a lot of flash, SRAM, peripherals and 44 pins. This one is definitely overpowered for a dawn simulator.

The ATtiny45 is the opposite, it has only 8 pins, some flash, some SRAM and not so many timers and stuff. But a dawn simulator doesn’t have to do very much. One timer for the light PWM, an I²C Bus for the display (more on this later) and the other pins for the input. This doesn’t seem too bad.
The display I’m using comes with an Arduino library which is no problem, because you can use an Arduino library without an Arduino, but this library buffers the whole display in the RAM. And because of the size of the display this buffer takes up 512 bytes, which is more RAM than the ATtiny45 has. So it is also not usable.

The Arduino Pro Mini with its ATmega328P is in-between, but I normally don’t use Arduinos so I actually never considered it, but it is the best one for this task.

#### Display

I have some old mobile phone displays, LCD dot displays and two monochrome OLED displays from Adafruit laying around. The OLED display has the big advantage that the black pixels are really black, so there is no black glowing in the night.
This is the display I’m using: https://www.adafruit.com/products/931

#### Light

For the light I choose two white 5W LEDs. They need a voltage of 17V and the µC controls them with a MOSFET. I found an IRL3803 that is rated with 140A, enough for two LEDs.

I built the circuit on breadboard like this:

GND wires
+5V
+17V
I²C Bus
Cables to the switches
PWM signal
Other connections

I have an LDO built in my breadboard “housing” and so no need for an extra LDO on the breadboard. All the other circuit is pretty self explaining I think.

Final image of the circuit:

Here you can see I put the LEDs on the metal for cooling.

# Arduino Code

To bring the circuit to life the µC needs code. I finally ended up using Arduino, its perfect for prototyping because it helps you with a lot of stuff.

### Libraries

I used the following libraries:

3. Time Library https://www.pjrc.com/teensy/td_libs_Time.html
4. TimeAlarms https://www.pjrc.com/teensy/td_libs_TimeAlarms.html

### Code Parts

The code is split up in five parts:

The core contains the setup() and loop() functions and the time-keeping and alarm code.

The input part handles the buttons. It detects button down and a long press.

The program can be in multiple states e.g. show time, change time or change sunrise duration.

The pwm part initializes the timer and calculates the sunrise.

This code draws everything on the display.