Introduction: DIY Bed LEDs - Time and Motion Activated [Video Tutorial]
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!
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:
- LED strip
- I used warm whites for a pleasant glow
- 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
- 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!
- Used to controll the LED strips
- I used the IRLZ44N, click here for datasheet
- Needs to be 12V to power the LEDs
- The current rating affects the length of LED strip you can use
- 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
- Power lost to current through resistance
- Tells you how much the MOSFET will heat up for one watt without a heatsink
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!
If you liked this instructable take a second to vote for me in the upper right corner!
We have a be nice policy.
Please be positive and constructive.