Categories
TUTORIALS

Motion & Light Detection Sensing with Arduino

Have you ever wanted to be able to activate an LED light at night but be able to deactivate it during the day? This tutorial will be your step-by-step guide on how to use a photoresistor to sense when an area is dark and turn on your LED light. This tutorial is a part of a larger project where LED strips are wired in such a way that detects a person/runner and lights up both the closest LED to the person and also detects the direction of motion in order to light up a dark running trail. 

Before we dive into the wiring here are the parts you will need: 

  1. Arduino Uno             
  2. Jumper wires              
  3. LED    
  4. PIR Sensor         
  5. LDR Photoresistor 
  6. Resistor 1k ohm
  7. Resistor 100 ohm  
  8. Breadboard

Next, we have the wring which can be viewed in the diagram below. The wiring is rather simple but you should note that the shorter side of the LED ( the cathode) should be aligned with the digital pin 3, and the longer side (the anode) should be aligned with the resistor.

One you have your parts wired, plug your Arduino to your power source. This tutorial uses an USB plugged into a computer, however you may use another power source like a battery. Open up the Arduino program and copy the code below. The code is commented out and explains how each part functions.

Once you have uploaded your sketch, try turning the light on and off and moving in front of your arduino. The LED should turn on either when the lights are off or when there is motion. The LED should be off when there is light and where there isn’t any motion. The idea is that the light dependent resistor should activate the LED if it is dark or the PIR sensor will activate the LED if movement is detected.

Have fun!

Tutorial by Kendra Hills

Leave a Reply

Your email address will not be published. Required fields are marked *