Random Nerd Tutorials
Share

Build a Night Security Light with Arduino

Share

In this project you’re going to build a night security light with a relay module, a photoresistor and an Arduino.

night-security-light-gif

A night security light only turns on when it’s dark and when movement is detected.

Here’s the main features of this project:

  • the lamp turns on when it’s dark AND movement is detected;
  • when movement is detected the lamp stays on for 10 seconds;
  • when the lamp is ON and detects movement, it starts counting 10 seconds again;
  • when there’s light, the lamp is turned off, even when motion is detected.

Recommended resources

The following resources include guides on how to use the relay module and the PIR motion sensor with the Arduino, which might be useful for this project.

Parts required

Here’s a complete list of the parts required for this project:

Besides these electronics components, you also need an AC male socket, an AC wire and a lamp bulb holder (a lamp cord set). My lamp cord set is the one in the figure below.

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Code

Download or copy the following code to your Arduino IDE, and upload it to your Arduino board.

Warning: do not upload a new code to your Arduino board while your lamp is connected to the mains voltage. You should unplug the lamp from mains voltage, before upload a new sketch to your Arduino.

Schematics

cloud-download

Here’s the schematics for this project.

Note: if you have an earth (GND) connection in the mains voltage cable – a yellow and green cable – it should go outside the relay module, like the blue wire (neutral).

Demonstration

Here’s your circuit in action:

night-security-light-gif

Wrapping up

In this project you’ve built a night security light with a photoresistor and a PIR motion sensor.

This is a great project to practice with relays and with the PIR motion sensor.

If you like Arduino projects, make sure you check our latest Arduino course: Arduino Step-by-step Projects – Build 25 Projects

Thanks for reading,

Sara Santos


Learn ESP32 with Arduino IDE

This our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks! The registrations are open, so SIGN UP NOW »

Leave a Comment:

Add Your Reply

⏰ Registrations are open ⏰
Sign up for "Learn ESP32 with Arduino IDE" Course