Introduction: Sunrise Alarm Clock With Arduino

Picture of Sunrise Alarm Clock With Arduino

Wintertime can be sad. You wake up, it’s dark and you have to get out of bed. The last thing you want to hear is the blaring sound of your alarm clock. I live in London and I have a hard time waking up in the morning. Also, I miss waking up to natural light.

In this tutorial, we are going to build a Sunrise Alarm Clock. It's an alarm clock like any other in that you can set the hour and minute you want to wake up, but with the added benefit of using light to brighten up your bedroom over a period of time like a sunrise to wake you up more naturally.

Sunrise lamps exist on the market but they can be expensive (a quick search on Amazon returns products in the £100 range), fragile and quite clinical-looking. We are going to make something a lot cheaper and a lot nicer.

All the parts will be listed in the next step. The code can be downloaded from my Github repo gold-sunrise-clock. All of the schematics and build files for the case are available to download on this tutorial.

Let's go :)

If you encounter issues or want to say hi, drop me a line celinechappert@gmail.com or follow me on Instagram @celinechappert.

Step 1: Gathering the Components

Picture of Gathering the Components

To start off, we'll be using a clock as our input and an ultra-bright LED as our output to simulate our sunrise.

To build the circuit we will need :

- a clock. We are going to be using the RTC DS3231 (£5)

- a MOSFET to control the brightness of the light (£9)

- a super-brightLED (£1)

- 9V battery to power the LED (£3)

- a breadboard for easy assembly (£3)

- an Arduino Uno (£20)

- a pushbutton (optional - for demo purposes only)

Total price=£41.

If you already have an Arduino, a breadboard and a 9V battery at home, the whole project will cost you less than £15.

To make the acrylic case you will need :

- 2 sheets of 0.3mm Perspex acrylic sheets, 1 sheet per color for the sun and the case.

- access to a laser-cutter.

I'm lucky to have had access to my school's workshop so these costs were covered for the most part. I did buy an extra sheet of acrylic because my design required an orange hue for the sun, which cost £14/sheet (Perspex is expensive!).

Step 2: Assembling the Circuit

You can refer to the black & white sketch of my circuit (excuse the messy) and to the diagram featuring the Arduino (done with Fritzing).

Essentially here is a breakdown of what is connected to what :

Clock :

(-) connects to GND

NC stands for 'Not Connected' and doesn't connect to anything

C/SCL connects to pin A5 on the Arduino

D/SDA connects to pin A4 on the Arduino

(+) connects to 5V on the Arduino

MOSFET

Gate pin goes to pin~9 on the Arduino Uno because it's PWM

Drain pin goes to the negative side of the LED

Source pin goes to GND on the Arduino

LED

Negative side is connected to the drain pin on the MOSFET

Positive side is connected to 5V on the breadboard

9V battery

(+) to (+) on the breadboard, same with (-).

Arduino Uno

Remember to connect 5V to (+) on the breadboard and GND to (-). Remember to connect (-) on one side of the breadboard to (-) on the other side.

Next up we'll be setting our clock using the DS3231 library.

Step 3: Installing and Setting the Clock

Picture of Installing and Setting the Clock

The library that I'm using to run this clock can be found at Rinky-Dink Electronics (screenshots above). Click on the link and make sure you are on the DS3231 page. Download the zip file, save it and place it in your Arduino's /libraries folder.

Now to set the correct time on the clock, open Arduino and go to Examples/DS3231/Arduino/DS3231_Serial_Easy.

Uncomment the three lines of code (outlined in orange in the screenshot), check the time and place that correct time in those three lines of code in military format.

Press Upload.

Now you can uncomment those three lines and press Upload again.

Open your Serial Monitor and check that your time is correct.

Our clock is set ! We have our circuit, now let's start coding. Again, the repo is available on Github.

Step 4: Coding

Download the code and make sure the library for the DS3231 is correctly installed.

First off we want to define our settings.

fadeTime is how long the light will fade from 0 to it's maximum brightness in minutes. setHour/setMin correspond to the time we want to wake up to (note: this reads military format, so 24hr time is required). We also define pin 9 on the Arduino as our OUTPUT.

In setup(), make sure the SerialBegin number (here 96000 baud) corresponds to the Serial Monitor's number.

In loop(), an if statement checks to see if it's time to wake up. The code runs on a loop, checking every time if the hour and minute values returned by the clock correspond to our setHour/setMin variables. If that's the case, the if statement returns an active() function.

The active() function is made of two parts. First we begin fading the light gradually : the delay functions are here to prevent the LED from becoming too bright too soon in the 'early' stages of the fadeTime. Then a for loop controls the speed at which the light should get brighter and brighter depending on the fadeTime. Finally, we shut the light off by passing a value of 0 to our LED in the analogWrite() function.

The video above shows the circuit working in one of the prototype acrylic cases.

Step 5: Cardboard Prototype (optional)

Picture of Cardboard Prototype (optional)

Prior to this project, I had never worked with a laser-cutter. Making a cardboard prototype enabled me to get familiar with the machine while testing how well the object looked (size, look etc) in real space. Case plans for download.

Step 6: Acrylic Prototype (optional)

Picture of Acrylic Prototype (optional)

For the second prototype I chose to refine my design using color and a different material. In the pictures I am using 0.3mm thick Perspex acrylic. I cut the design twice, once in each color and then assembled the pieces to create the sun. I appreciate how the semi-opaque acrylic diffuses the light nicely, we are getting closer to the original vision of replicating a sunrise.

Step 7: Designing and Lasercutting the New Case

Picture of Designing and Lasercutting the New Case

The new case is a bit smaller, perfect for a bedside table and picking orange over yellow for the sun creates a more contrasted look. Rounded edges are also preferable because there are less chances of the pieces breaking when taking them out of the laser-cut acrylic sheet (it's a physics thing, forces focus more at angles, I didn't know until today). Case plans ready to cut are also available for download.

Step 8: Putting It All Together !

Picture of Putting It All Together !

We have our circuit, we have our case and now we can put it all together ! I really love the brightness of the LED getting brighter and brighter behind the sun. The different pieces of acrylic that make the box fit nicely together, so all you need is some glue specific to plastic and you're set.

Step 9: Conclusion

Picture of Conclusion

I'm very happy with the final result, it was a good learning experience working with super-bright LEDs and other electronics and a good introduction to the laser-cutter. The smaller size is preferable as it stands nicely on a bedside table. The gradual brightness of the LED was enough to wake me up on cold London mornings so I can say the project was a success ;)


Ideas for further development:

- To make our sunrise even more beautiful and realistic, we could make use of RGB LEDs to replicate the palette of the sunrise with a gradient of deep blues to reds/oranges.

- To make our circuit more sturdy, we could solder all the components together or connect them with a printed circuit board. I didn't do this on purpose in order to be able to re-use my components for other projects.

- It would be nice to add a small LCD display to change the waking time without having to dig into the code, same goes for changing the fade time.

- To go further with material exploration, we could experiment with light diffusing through different mediums. I chose acrylic because it was free for me to use but colored plexiglass or frosted mylar could give amazing results. For the next project I will look into working with Hamar Acrylic in London.

Follow me @celinechappert on instagram and say hi if you liked the project ;)

Comments

About This Instructable

621views

22favorites

License:

Bio:Light tinkerer. Paris / San Francisco / London
More by celinechappert:Sunrise Alarm Clock With ArduinoFiber Optic LED Chandelier
Add instructable to:
nydailynews.com, e-hentai.org, ehow.com, superuser.com, chron.com, lefigaro.fr, wikiwiki.jp, abcnews.go.com, php.net, nbcnews.com,