Programable Motion Sensing Night Light

by Dan Chen in Circuits > LEDs

7040 Views, 188 Favorites, 0 Comments

Programable Motion Sensing Night Light

Programable Motion Sensor Night Light
DSC00825.jpg
DSC00860.jpg
DSC00824.jpg
DSC00829.jpg
DSC00880.jpg
DSC00834.jpg
DSC00833.jpg
DSC00819.jpg
DSC00817.jpg
DSC00874.jpg

I always have trouble finding light switches during the middle of the night in the dark or entering a pitch black room when I get home. That is why I created this customized and programmable night light.

For this custom design night light I want to have the following criteria

  • Motion activated
  • Light slowly fades on and off
  • looks good
  • cheap
  • programmable
  • usb powered
  • Sensor sensitivity adjustment
  • good night light or motion activated light

For this project you will need

  • Hot glue
  • Laser Cutter
  • Acrylic
  • Sand Paper / Sand Blaster
  • Motion Sensor / HC-SR501
  • Attiny 85 / Adafruit Trinket / or any micro controller
  • Mini or Micro USB Female Jack
  • LED Strip or USB LEDs (Warm White)

Laser Cutting

IMG_1834.jpg
IMG_1921.jpg
IMG_1922.jpg
IMG_1926.jpg
Screen Shot 2016-01-10 at 10.09.19 AM.jpg
IMG_1928.jpg

I used 1/4 inch Acrylic for this project. The cut lines in the middle will create 2 pieces for us to interlock, there will be very little waste but does not allow us to friction fit the pieces.

You can download the cut file HERE.

It will take a little while to cut through 1/4 inch acrylic, you might need to do multiple passes to cut through.

Sanding

IMG_1930.jpg
IMG_1934.jpg

After cutting all acrylic pieces, I removed the protective film then sand blast the surface at 60 PSI, you can also use 800 grade sandpaper for this. make sure you do this for both sides.

Assemble + Electronics

IMG_1938.jpg
IMG_1936.jpg
IMG_1937.jpg
515HOdDRv0L._SY450_.jpg
IMG_1939.jpg
IMG_1962.jpg
IMG_1984.jpg

The motion sensor should fit perfectly to the acrylic piece that has a circle on it. If you are using a smaller motion sensor, you will need to modify the ESP file.

Use the square end pieces to secure the whole structure. You can use acrylic glue, but here I am using hot glue from the inside instead because it's faster and won't leave melted acrylic glue mark.

I took a micro usb male to female extension cable and fitted it to one of the end piece that has a rectangular hole. You should resize this hole in the included ESP file before cutting just in case they are different. This port will provide the power and ability to program.

I purchased these cheap and bright LEDs from amazon, but they are touch activated, so I disable them by solder the pins as marked(red) in the attachment.

Wiring

Trinket is programable via USB via the extension cable which leaves the female jack on the exterior.

I wired the LED's + VCC to pin 4 on Trinket and LED's GND to Trinket's GND.

I wired the sensor pin to pin 1 on Trinket.

Coding

The following code is for trinket from adafruit

//////////////////////////

int led = 4; // the pin that the LED is attached to on trinket
int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by boolean triggered=false;

void setup() { pinMode(led, OUTPUT); }

// the loop routine runs over and over again forever: void loop() {

int sensorValue = analogRead(1);

delay(10); // delay in between reads for stability

if (sensorValue > 100) {

if (!triggered){ for (brightness = 0; brightness <= 255; brightness += 1) { analogWrite(led, brightness); if (brightness==255) {triggered=true;} delay(30); } } else{ delay(10000); }

} else { if (triggered){ for (brightness = 255; brightness >= 0; brightness -= 1) { analogWrite(led, brightness); delay(80); if (brightness==0) {triggered=false;} } } }

}