3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Simple Arduino Sunrise Lamp

Simple Arduino Sunrise Lamp
Hate waking up in the dark? Me too.  I found a cheap 24 LED lamp and thought it would be fairly easy to make it turn on slowly using my Arduino, which should help banish some of those "waking up in the dark" winter blues.

You'll need:
- a "camping" LED lamp- I used one like this one
- an Arduino or other programmable microcontroller
- a timeswitch
- a "wall-wart" power supply
- transistors capable of switching about 500mA
 
Remove these adsRemove these ads by Signing Up
 

Step 1Pulse width what now?

Pulse width what now?
A little background:

LEDs aren't like incandescent lightbulbs in the way they dim.  If you supply an incandescent lightbulb with a reduced voltage, it doesn't put out as much light.  LEDs don't work quite like this, and tend to turn on suddenly with a small increase in voltage.  The usual way of dimming LEDs is to turn them on and off very quickly- this is known as pulse-width modulation (PWM), because by varying the amount of time the LED is switched on (the pulse width) you can control precisely how bright it appears.

All we need to do is write a simple program that will turn on the LEDs dimly at first, with short pulses separated by longer periods of being switched off, and gradually increase the length of each pulse so making the LEDs appear brighter.

This gets a little bit more complicated when you involve the human eye.  It turns out, if you halve the amount of light an LED is actually producing, it appears more than half as bright.  The human eye perceives a very small difference in low light levels as significant, but doesn't notice small differences between higher light levels.  This means if we were to brighten the LEDs uniformly (starting at 10% brightness, then 20%, then 30% and so on) to a human observer it looks like it gets brighter very quickly at first, then slowly increases through higher levels of brightness.  To compensate for this we need to switch the LEDs on more slowly at first, then accelerate through higher light levels.

If that all sounds overly complicated to just turn some lights on, don't worry- I've done the maths so you don't have to!
« Previous StepDownload PDFView All StepsNext Step »
10 comments
Dec 13, 2011. 6:23 AMjcalbeto says:
Wow! I am impressed!

I am working on a prototype that consists in a sensor (I don't know yet what sensor, maybe pressure sensor or light sensor) that switches on a set of LEDs that gradually light up (during 6 min more or less). At the end, there is a second sensor to switch off the light when wanted.

I am familiar with Arduino and I am able to understand more or less the easy code but I am not able to write it. So your code is exactly what I was looking for, thanks so much!

But I have some questions on how to addapt it:

- Which value should I write at the sunrisespeed to increase the time to 6 minutes? I messed up the maths...

and

- How do I mention the sensors to switch on and off the light at the code?


If you could respond in a short time I would really appreciate it!
Thanks a lot for your help!
Dec 14, 2011. 2:08 AMjcalbeto says:
Thank you PKM!
I think I will manage with that!
Nov 9, 2011. 8:49 AMgerrymoore5 says:
Hi...this works perfectly but I want the light to stay on full brightness at the end of the lookup table...I was good with BASIC but not sure how to add this to the ardunio code...any ideas please...Gerry
Nov 10, 2011. 12:22 AMgerrymoore5 says:
That's great!! I was looking at 'if then else' statements but the answer is so much simpler!!

As I want to build this as a permanent (winter) addition to our bedroom, and as I would prefer not to tie up my Arduino board, would it be possible to use this code on a little 8 pin Pic? I have a pic programmer but, as with the Arduino code, I struggle with the syntax for the language.

I am very impressed with the code...it seems very compact yet the 64 levels of brightness work perfectly...thank you for posting it.

cheers Gerry
Nov 10, 2011. 7:58 AMgerrymoore5 says:
No probs...I need to learn anyway!!!! I'm pretty sure they have internal crystals so the delay should not be a problem....beauty is, it costs nothing to try :-))

Thank you again for your quick replies.....Gerry.
Sep 20, 2011. 6:38 AMdmcvey1 says:
Awesome project! I would love to do this project! However, I am very unfamiliar with Ardiuno. It is hard to tell the difficulty scale of this project. How long did this take you to do? Also, do you have more pictures of the final product?

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
148
Followers
17
Author:PKM