Arduino Light Sensor and Alarm

Introduction: Arduino Light Sensor and Alarm

About: I go by millerman4487, and I am here to share what I make. Hopefully, you can learn from watching what I have done and even improve upon it. So here you go! If you have any ideas for future projects, send...

This is a design of mine that you place inside of a box, drawer, or fridge and plays an alarm noise whenever you open the box, drawer, or fridge. It uses a light-sensitive resistor and is quiet when it is dark(the box is closed) and plays a noise when it is light(the box in open). It works especially well in the refrigerator, since a light comes on when you open it. You can use this to protect your things, annoy people, or help you stay on your diet by playing an annoying noise when you open the fridge.

Step 1: Gather Parts

You will need:

>a photoresistor (I use an R4)

> a 10kΩ resistor (brown-black-orange)

>a piezo buzzer

>a 9v battery and battery clip

>an Arduino board

>a Breadboard

>Jumper wires

Buy Specialty Parts:

photoresistor -

piezo buzzer -

Step 2: Put Parts in Place

Not much explaining to do here; just follow the picture.

Step 3: Wire It Up

>Photoresistor goes to 5v, and ground through the resistor. Ground side of photoresistor goes to analog pin A2

>Piezo Buzzer goes to ground, and digital pin 2

>9v battery goes to ground and the Vin pin on board

Step 4: Coding

Connect your Arduino to your computer and upload this code:

const int dark = 200; //set dark parameters
const int sound = 50; //set noise to play
void setup() {
  pinMode(2, OUTPUT);
  pinMode(A2, INPUT);
void loop() {
  int light = analogRead(A2);
  if (light < dark) {
    Serial.println("  It's dark");
  else {
    Serial.println("  It's light");
    tone(2, sound, 10);

Mountain View

Open the Serial Monitor in the Arduino program, and watch what happens!



    • Tiny Home Contest

      Tiny Home Contest
    • Fix It! Contest

      Fix It! Contest
    • Furniture Contest 2018

      Furniture Contest 2018


    This is a pretty cool idea. I like how you made it modular. Good work.