loading

Today I'm showing you how to make your bed glow!

This works by having a LED strip hidden under the frame of your bed. This will give off a pleasant glow illuminating your room from downwards and up.

The lights are either activated by the time of day or when it detects motion. I've attached my code and made it easy to tweak and edit to suit your needs.

Now you will never be blinded by light if you wake up in the middle of the night again!

Let's get started!

[Play video]

If you like this instructable take a second to vote for me in the upper right corner!

Step 1: Parts and Tools

To make this project you are going to need the following:

Parts:

  • LED strip
    • I used warm whites for a pleasant glow
  • Microcontroller
    • I prototyped on an Arduino UNO and used an Arduino Pro Mini in the final circuit
  • PIR sensor
    • Passive InfraRed = PIR
    • Used to detect motion
  • RTC module
    • Precise way of telling time on microcontrollers
    • Comes with it's own battery so it will still keep the time if you power off your Arduino!
  • MOSFET
    • Used to controll the LED strips
    • I used the IRLZ44N, click here for datasheet
  • Power source
    • Needs to be 12V to power the LEDs
    • The current rating affects the length of LED strip you can use

Tools:

  • Soldering iron
  • Hot glue gun
  • Wire cutters

Step 2: The Plan

Like all good projects I started this by prototyping on a bredboard with an arduino UNO. Instead of starting with the LED strip I just toggled and faded on and off a single LED. This let me be sure everything worked before I made the whole project more complex.

It's a good idea to start prototyping with a project in it's simple form. That way, when things go wrong and you need to do some debugging. You'll have an idea of when the problems started and at what level of complexity.

When the code worked I went on to control the LED strip in the same manner as the single LED. I wanted to use PWM to fade the LED strip on and off, instead of just turning it on and off abruptly. To achieve this I used a MOSFET. I'll explain how to look for a suitable MOSFET in a later step.

When everything worked it was time to pack it together and mount it under the bed. Another benefit of spending time on prototyping is that I wouldn't have to debug my software and circuit after it was mounted under the bed. That would have been a pain!

Step 3: Code and Circuit

The way the code works is by the RTC communicating the time to the arduino.

  • If the time is in the evening - 20:00-21:30 - the code goes through a loop to fade on the lights
  • After 21:30 and before 06:30, the system enters Motion Detection state. The motion sensor outputs a digital-LOW/HIGH signal whenever movement is detected. This turns on the lights and fades them off again if there's been five minutes without movement. Perfect if you have to get up in the middle of the night!
  • Finally, if the time read is between 06:30 and 08:30, the LEDs will turn on to act as a wake up light. Making your mornings a bit more pleasant compared to complete darkness

I wrote the code to be beginner friendly with lots of comments, so I encourage you to poke around!

The RTC has its own battery for time keeping and the time is automatically set from your computer when you upload the code.

The complete code uses the RTCLib which you can download here.

As you can see in the schematic, the single LED gets replaced by the gate-connection to a MOSFET. This means that whenever the Digital Pin 9 is set to HIGH, the LED strip's negative terminal is connected to ground on the power source.

Step 4: Deciding on LED Strip Length

I'm going to connect the arduino and LEDs in parallel on a 500 milli-amp power supply.

We need to determine the current draw of the arduino to know how much power is left for the led strip. This is measured by connecting a multimeter in DC-current mode, in series with the power running to the arduino.

I'm measuring 60 milli-amps draw from the arudino, this will be a good ballpark for you as well. So you won't have to measure the current of your own arudino.

The acctual current drawn will be slightly less when we replace the single LED with a MOSFET. This is because a MOSFET is switched by voltage potential and will theoretically not draw any current in doing so.

If we do some math we find we can power 66 leds or 1.1 meters of led strip, in parallel with the arduino. I wanted a slight margin, so I used a one-meter strip for under my bed. You can see my exact calculations in the picture!

Step 5: MOSFET

All I know about picking the right MOSFET I learned from Tom's guide.

Here's what you need to know:

  • RDS(ON) = Drain to Source On Resistance
    • Internal resistance used in power calculation
    • Calculating with a 20-30% added resistance value
    • Find the resistance at your voltage level
  • PLost = R * I^2
    • Power lost to current through resistance
  • RθJA = Thermal Resistance Junction to Ambient
    • Tells you how much the MOSFET will heat up for one watt without a heatsink
  • Total = RθJA + TAmbient [25 degrees]

Step 6: Packing and Mounting

I soldered everything together to make it a bit more compact and to get more secure connections. I chose to switch out the arudino UNO with the arduino Pro Mini for several positive reasons: It's so much easier to solder onto, much smaller form factor, and you can buy it for only $2 !

To make the complete circuit easier to handle I soldered it onto a perf board. I then secured some of the connections with hot glue, and taped the RTC module onto the perf board. Leave the PIR sensor loose though! This will be mounted so it's looking onto the floor that leads to the bed.

Now you just peel off the protective glue backing on the LED strip and you can stick it under the bed. The glue sits much better on wood than on fabric, so fasten it onto the wood frame. Don't worry about the lights being weak from this. Even when the LED strip is pointed straight downwards to the floor, it will be really bright and cast a nice glow into your room!

The circuit and perf board was mounted under the bed with hot glue. I stuck a piece of duct tape to the backside of the wooden frame and perf board, and stuck these parts together with hot glue. This is just to make it that much easier to remover the electronics if you ever have to!

I wondered for a while on how to best mount the PIR sensor so it would look onto the floor. The solution I came up with was bending a paper clip to hook into the mounting holes on the sensor. The paper clip can then be mounted under the bed with a small piece of duct tape. This is a pretty strong, yet easy to remove and adjust mount for the sensor.

Pro tip for uploading to the Pro Mini: Stick the Pro Mini pins into a tiny bredboard and then stick an FTDI programmer into the adjacent bredboard pins. I find this is the easiest way of connecting the FTDI programmer to the Pro Mini. Now you just plug in the USB cable and upload the code!

Step 7: Final Thoughts

That's it guys - we're done!

Just plug in the power supply and now you'll always wake up to a pleasant glow!

The mornings in my place have begun to get much darker, so it really helps me get up in the morning when I wake up and the room is already illuminated!

What's more, if I wake up in night I can just shuffle out of my bed and the light is slowly faded on, filling my room with a soft and warm light. Never to be blinded in the night again!

Click here to play the video!

If you liked this instructable take a second to vote for me in the upper right corner!

<p>Hello, </p><p>first of all I would like to say thank you for making such a great project ! I just start playing little bit around with arduino recently and seeing your project make me think I can build it but I straggle a bit . So I would like to ask you a question. Would it be possible to run the same example and code on 5m long LTE strip with 60 LED /m , power 4.8 W/m and two PIR sensors ? I guess I will need stronger power supply around 24 W and different MOSFET and stronger resistor? I would appreciate any advice you can give me to make it work around my whole bed, surely there is a lot to learn for me ;)</p>
<p>Hey,</p><p>I am using Arduino with RTC to operate the lights of my home.</p><p>I want at 10 PM all my lights should OFF and at 6 AM same should be ON.</p><p>I have completed everything but only unable to tell Arduino to read time from RTC to operate lights.</p><p>Can it be done by reading Arduino Serial Monitor? If yes, then HOW.</p><p>Also the other possible method to do same through Arduino.</p><p>Thanks.</p>
<p>Changing the time is no problem just look at line 13 and 14 in the code!</p><p>Edit the lines to this:</p><blockquote>const int onHourAM = 6, onMinuteAM = 0, offHourAM = 8, offMinuteAM = 30; //morning time</blockquote><blockquote>const int onHourPM = 20, onMinutePM = 0, offHourPM = 22, offMinutePM = 0; //evening time</blockquote><p>The arduino reads time over I2C. This is done on analog input pin 4 and 5 on arduinos who use the ATMEGA328 micro processors. In other words, on both the arduino UNO and Pro Mini, connects the SDA and SCL from the RTC to analog pin 4 and 5.</p><p>What arduino version are you using?</p><p>Check the serial monitor and see if everything works.</p>
<p>Thanks for reply.</p><p>I am using Arduino UNO with dedicated SDA and SCL pin.</p><p>I've already set up the time and date in DS3231 RTC and it is even showing in Serial Monitor..</p><p>But The main problem I am facing is-- DS3231 is printing time in Arduino serial monitor and I want Arduino to Read that particular (pre-decided) time from Serial monitor and execute the task.</p><p>Suppose serial monitor is printing hour, minute and second as :</p><blockquote>21:59:57<br>21:59:58<br>21:59:59<br>22:00:00 I want Arduino to read this moment as it shows<br>22:00:01 22:00:00 either through Serial Monitor or Directly<br>22:00:02 from DS3231 and execute the desired task.<br><strong>Your </strong><strong>assistance would be </strong><strong>appreciated</strong>...</blockquote>
<p>hello plz help me when i switch off arduino time is stoped i checked rtc module its fine ok on other platform.</p>
<p>Might be the battery is either dead or put in wrong. Check the voltage of the RTC battery with a multimeter and see what it reads!</p>
<p>thnx problm solved but somtime when i restart arduino leds does not on again in evening even not go to motion state ir kindly guide me whats problem in serial monitor when i check time is updated and rtc working fine this is my fav instructable.thnx</p>
<p>Okay this is good, your RTC and arduino are wokring. Have you tested your PIR sensor?</p><p>I'm thinking the issue comes from when you start running the arduino. The default way I've written the code means that you should plug in the power supply in the middle of the day. </p><p style="margin-left: 20.0px;">The code sets the boolean states to be equivalent to the middle of the day when it first powers on. So this means you should turn on the complete system in the time between 08:30 and 20:00.</p><p>Try that and see how it goes!</p>
<p>Great project :)</p>
<p>Thanks Maria!</p>
Great<br>Thnx
<p>Pleasure was all mine!</p>
Nice well made tutorial, keep up the good work! :)
<p>Thanks mate, I will! </p>

About This Instructable

3,178views

124favorites

License:

More by Sverd Industries:Gift Away Your Heartbeat for Valentines Day! | Arduino Tutorial Cacio E Pepe - Cheesy Comfort Pasta 3D Printed Utility Desk Shelf! - Video 
Add instructable to: