Introduction: Fancy Bed Night Lights

Picture of Fancy Bed Night Lights

This is the bed light system of the future! They turn on when you walk out of your bed in the middle of the night and turns off when you walk into your comfortable dream machine. So no more night accidents and smashed toes!!

This is super easy to built and your bed will look out of this world. So let's begin, shall we?

Step 1: Gather All Parts

Picture of Gather All Parts

Okey, in order to begin we need to have all the part required for this project. Please read this hole step before purchasing anything. So you will need:

  • An Adafruit Trinket 5V (https://www.adafruit.com/product/1501)
  • A breadboard (https://www.adafruit.com/product/64)
  • Some jumper wires (https://www.adafruit.com/product/153)
  • A 4k7 ohm resistor (https://www.adafruit.com/product/2783)
  • A velostat sheet (https://www.adafruit.com/product/1361)
  • Our LED strip (https://www.adafruit.com/product/2237)
  • A power supply(https://www.adafruit.com/product/1466)
  • And of course a bit of tape, aluminum foil and a thin cardboard
  • Some tools like pliers, scissors and soldering iron.
  • A bit of electrical tape and kapton tape.
  • A bed rug of course!!!

As you probably can see I am a big fan of Adafruit products, however you can use other LED strip models. This is up to you, my code has a lot of options available. In my setup I used 50 LED SM16716 modules, feel free to use as much leds as you want and any model the code supports. But consider a proper power supply for your setup, remember that most rgb strips can need as much as 60 mA per LED. So you are warned!

Step 2: Built the Sensor Rug

Picture of Built the Sensor Rug

This is probably the longest part of this tutorial, but it's easy. Please use the photos as reference and follow this steps:

  1. Cut two aluminum foil sheets a bit smaller than the velostat sheet.
  2. Then use some electrical tape to join the 3 sheets, remember that in the middle goes the velostat sheet. Also let a small space free of tape for the wiring.
  3. Use some copper tapper to create electrical contacts, one goes in the bottom aluminum foil and the other one in the top.
  4. Solder wires to the attached copper tape and use some kapton tape to protect the connection.
  5. Then use a thin cardboard from protect the aluminum foil from ripping, this sheets must be the same size as the entire sensor. Secure it with more electrical tape. Also be careful of letting a small space without tape or make a tiny hole in both aluminum and cardboard to allow air escaping without making damage to the sensor.
  6. Is everything is okey you now have a fully functional stepping sensor!!!

Note: I used the plastic bag that came with the velostat sheet to protect the sensor from humidity, just slip it in :)

Step 3: Mount the LED Strip on Your Bed

Picture of Mount the LED Strip on Your Bed

Now let's go to the fun part of this project, attach your lights to your bed!!! I will not enter in much details with this, just be creative and do the way you want. But if you need a bit of inspiration I put mines every few centimeters and I used masking tape to fixing it to the bed.

Feel free to use as many Leds as you want, in the position and distance you want :)

Step 4: Program the Trinket

Picture of Program the Trinket

Okay, first of all you will need to learn how to use the Trinket. Luckily adafruit has a great tutorial right here. When you are ready come back to the action.

I see, you have returned. You now know how to load programs to the Trinket with Arduino and the basics, probably you have done a Blinky demo :)

Now download the great FastLED library from GitHub and install it. And then put my code in your trinket, is programmed to turn the LED's in blue with a small animation. But feel free to modify anyway you want, remember to configure the number of leds you are using and the type of strip.

<p>//This project was created by Danni Fernandez<br>#include <avr power.h="">#include "FastLED.h"
#define NUM_LEDS 50 //how many leds your strip has#define DATA_PIN 0 //data line for your strip #define CLOCK_PIN 1 //clock line for your strip, is your strip dont have this comment it#define SENSOR_PIN 1 //where the sensor is connected, on the adafruit trinket analog pin 1 equals to digital pin 2#define TRIGGER 50 //the value below whe consider someone is stepping 
CRGB leds[NUM_LEDS];
int inicialization = 0;int state = 0;
void setup(){  if (F_CPU == 16000000) clock_prescale_set(clock_div_1); //whe want the trinket runnig at 16MHZ, pleaso also select it on the board menu
  // Uncomment/edit one of the following lines for your led strip that are you using  // FastLED.addLeds<tm1803, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<tm1804, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<tm1809, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<ws2811, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<ws2812, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<ws2812b, data_pin,="" rgb="">(leds, NUM_LEDS);  //FastLED.addLeds<neopixel, data_pin="">(leds, NUM_LEDS);  // FastLED.addLeds<apa104, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<ucs1903, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<ucs1903b, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<gw6205, data_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<gw6205_400, data_pin,="" rgb="">(leds, NUM_LEDS);
  // FastLED.addLeds<ws2801, rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<sm16716, rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<lpd8806, rgb="">(leds, NUM_LEDS);  // FastLED.addLeds
<p9813, rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<apa102, rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<dotstar, rgb="">(leds, NUM_LEDS);
  // FastLED.addLeds<ws2801, data_pin,="" clock_pin,="" rgb="">(leds, NUM_LEDS);  FastLED.addLeds<sm16716, data_pin,="" clock_pin,="" rgb="">(leds, NUM_LEDS); //in my case this is my strip model  // FastLED.addLeds<lpd8806, data_pin,="" clock_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds
<p9813, data_pin,="" clock_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<apa102, data_pin,="" clock_pin,="" rgb="">(leds, NUM_LEDS);  // FastLED.addLeds<dotstar, data_pin,="" clock_pin,="" rgb="">(leds, NUM_LEDS);
  inicialization = 1;  delay(500);}
void loop(){
  if (inicialization == 1) //turn off all leds in power on  {    for (int i = 0; i < NUM_LEDS; i++)    {      leds[i].setRGB(0, 0, 0);    }    FastLED.show();    inicialization = 0;    FastLED.show();  }
  if (analogRead(SENSOR_PIN) <= TRIGGER) //if someone is on the rug  {    if (state == 0) //is leds are off then do this animation for turning on    {      for (int i = 0; i < NUM_LEDS; i++)      {        leds[i].setRGB(0, 0, 20);        FastLED.show();        delay(100);      }      delay(200);
      for (int x = 20; x <= 125; x++)      {        for (int i = 0; i < NUM_LEDS; i++)        {          leds[i].setRGB(0, 0, x);        }        FastLED.show();        delay(20);      }      while (analogRead(SENSOR_PIN) <= TRIGGER); //wait until the person steps away      delay(2000);      state = 1;    }    else //is leds are on then do this animation for turning off    {      for (int x = 125; x >= 20; x--)      {        for (int i = 0; i < NUM_LEDS; i++)        {          leds[i].setRGB(0, 0, x);        }        FastLED.show();        delay(20);      }      delay(100);
      for (int i = 49; i >= 0; i--)      {        leds[i].setRGB(0, 0, 0);        FastLED.show();        delay(100);      }      while (analogRead(SENSOR_PIN) <= TRIGGER); //wait until the person steps away      delay(2000);      state = 0;    }  }  delay(200);}</dotstar,></apa102,></p9813,></lpd8806,></sm16716,></ws2801,></dotstar,></apa102,></p9813,></lpd8806,></sm16716,></ws2801,></gw6205_400,></gw6205,></ucs1903b,></ucs1903,></apa104,></neopixel,></ws2812b,></ws2812,></ws2811,></tm1809,></tm1804,></tm1803,></avr></p>

For the last version of the code get it on GitHub: https://github.com/Danny24/Bed_lights

Step 5: Built the Circuit

Picture of Built the Circuit

Is a pretty easy circuit, so it will only take us a few minutes to make this in our breadboard, :)

My connections are as follows:

  • 5V from power supply to BAT pin of the Trinket and Vcc of our LED strip.
  • GND from power supply to the Trinket, one wire of our rug sensor and GND of the LED strip.
  • Trinket pin 0 to data pin of the LED Strip.
  • Trinket pin 1 to clock pin of the LED Strip.
  • The other wire of the rug sensor goes to Trinket pin 2, also a 4k7 ohm resistor goes between this pin and 5V pin of the Trinket.

That's all, easy don't you think?

Step 6: Enjoy!!!

Picture of Enjoy!!!

Hide everything under your bed and put the sensor under the rug. Now you are ready to rock this project.

I hope you enjoy it and do a lot of hacking with the animations and lighting.

Thank you for reading me :)

Comments

About This Instructable

491views

12favorites

License:

Bio: I'm interested in new technologies and the things that we can make in house with a few components and a bit of imagination.
More by Danni FR:Fancy Bed Night LightsHow to load programs to an Arduino UNO from Atmel Studio 7Neopixel Clock
Add instructable to: