Introduction: Grab Alarm Using Arduino + LDR + Piezo Buzzer

Picture of Grab Alarm Using Arduino + LDR + Piezo Buzzer

This small project will teach you, how to make a simple Grab alarm using an LDR ( light dependent resistor).When you try to move your hand over the LDR, there is a loud alarm that goes on , and the alarm turns off as soon as you move your hand away from the LDR. The LDR works on the following principle " WHEN LIGHT FALLING ON THE LDR IS HIGH;RESISTANCE IS LOW ." and vice-versa. Basically for an LDR , light is inversely proportional to the Resistance.

You can follow the link to my blog :


  1. LDR ( you can choose any variant ), these come in various sizes ,usually based on the size of the area on which the light falls.
  2. Piezo buzzer (PCB MOUNT).
  3. Resistor (220ohm /1kohm)
  4. Connecting wires or Jumper cables
  5. Arduino UNO R3
  6. USB cable
  7. Breadboard

Step 2: Procedure

Picture of Procedure

1. Connect one terminal of the piezo buzzer to Digital pin 9(you can choose and PWM enabled pin) , and connect the other terminal to ground . Your buzzer connection is now complete.

2. Now make the connections similar to that given in the picture

  • the black wire goes to ground
  • the green wire goes to pin A0 on the Arduino
  • the red wire goes to the 5v pin on the Arduino

Step 3: Circuit Diagram and Schematics

Picture of Circuit Diagram and Schematics


Picture of SOURCE CODE :
int rcvpin=A0;
int buzzpin=9;
void setup()
void loop()
  int ldrval=analogRead(rcvpin);
  void buzz(unsigned char time)


  1. I have used ldrval variable to store the value being sent by the LRD connected to the arduino
  2. The value is then printed on the serial monitor . This following part is very crucial .
  3. After you have fully connected your circuit , you should upload your sketch to the arduino and then open the Serial monitor from the tools section on your arduino platform .
  4. If your sketch is working properly then it should send back some values to your serial monitor .
  5. Try to place your hand closer to the serial monitor and observe the readings changing .
  6. In this manner you have to decide what your threshold value will be ; crossing which your buzzer will start.In my case ,this value was 900. Try to play around with this value , as this decides the sensitivity of the Alarm going on.
  7. See the source code line 28 : you can also play around with the value . In my case i put it to 170 . You can use values ranging from 0-255 , where 0 represents off .



Ritika_sharma made it! (author)2017-03-29

simple and effective. I love to tinker with its values and the output was quiet effective when i put the values just around the sensitive point. thanks.

arshad118ar (author)2017-01-28

do the usb cable should be always connected with laptop/computer to work

arshad118ar (author)2017-01-28

hello shorbonB i love this project i want to know that where to set the secure code please tell me how to do it ...................if possible please send me a to set the secure code...................did i have to connect the the ardunio to the computer by usb

yanais (author)2016-02-08

Love this project :)!

try building the circuit with - you'll get a detailed schematic and code.

ShrobonB (author)yanais2016-02-08

Thanks a lot yanais , for appreciating my efforts :)

MsSweetSatisfaction (author)2014-08-16

Well that's one way to keep your valuables safe. Thanks for sharing!

Thanks for appreciating my work . This instructable now includes detailed circuit diagrams and schematics to make it easy for creating your own Project.

Thanks again :)

raj18349 (author)ShrobonB2015-06-17

Sir,my alarm keeps buzzing all the time even when i remove the LDR.. Plz help..

raj18349 (author)2015-06-17

Sir,my alarm keepd buzzing all the time plz help

raj18349 (author)2015-06-17

Sir,my alarm keeps beeping all the time even when i remove the ldr.plz help

Mauimacman (author)2015-03-24

Thanks for this. I am using it to tell me when a charging light for a lipo battery GOES OFF. Perfect. I set the threshold to 200 and left the rest. Next step to add code that tells me how long it took to charge the battery. That's a bit more coding knowledge than I have. I'll have to look at loop and counting codes and see if I can integrate an if then statement to stop the count. Any clues?

About This Instructable



More by ShrobonB:ARDUINO Burglar Alarm Using Infrared Emitter-Detector pairGrab Alarm Using arduino + LDR + piezo buzzer
Add instructable to: