Arduino-Based Shadow Alarm

Arduino-Based Shadow Alarm


Shadow alarms are usually used for protection against theft. A shadow alarm is a device that sounds an alarm when a shadow falls on it.Described here is a simple circuit of an arduino based shadow alarm.This compact shadow alarm unit is capable of sensing a moving shadow in a restricted area, and can be easily installed on wall, window or door to protect your valuables from theft.Constant lighting is required in the confined area to detect the moving shadow.


T1, T2 – BC547
D1,D2 – 1N4007
LED – 5mm light emitting diode
R1,R4 – 1k resistor
R2,R3 – 470 ohm resistor
VR1 – 4.7k preset
LDR – Light dependent resistor
C1 – 470uf, 25v electrolytic capacitor
C2 – 100uf, 16v electrolytic capacitor
CON1 – 7 pin male header
CON2 – 1 pin male header

Price from us for above = 150npr

Batt.1 – 9v battery
Arduino Uno


1) Connect arduino to your PC

2) Input this source code:

//shadow alarm by Jovian D’souza
int sensPin = 2; // Sensor Input Pin
int ledPin = 8; // Reminder LED Output Pin
int pzSpeaker = 10; // Piezo-speaker Output Pin
int val =0; // variable for reading the Input Pin status

void setup() {
pinMode(sensPin, INPUT); // set shadow sensor as input
pinMode(ledPin, OUTPUT); // set LED as Output
pinMode(pzSpeaker, OUTPUT); // Set Piezo-speaker as Output
void loop() {
val = digitalRead(sensPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // Turn LED ON
playTone(500, 600);
playTone(500, 800);
else {
playTone(0, 0);
// duration in milli seconds , frequency in hertz
void playTone (long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pzSpeaker, HIGH);
delayMicroseconds(period / 2);
digitalWrite(pzSpeaker, LOW);
delayMicroseconds(period / 2);
elapsed_time += (period);


3) Click on upload

Step 5: Connections to and from Arduino and board

1) Connect the 1st pin of the shadow alarm circuit to Vin of the arduino.
2) Connect the 2nd pin of the shadow alarm circuit to pin 10 of the arduino.
3) Connect the 3rd pin of the shadow alarm circuit to the LDR and other pin of LDR to Gnd.
4) Connect the 4th pin of the shadow alarm circuit to 5v of the arduino.
5) Connect the 5th pin of the shadow alarm circuit to pin 8 of the arduino.
6) Connect the 6th pin of the shadow alarm circuit to pin 2 of the arduino.
7) Connect the 7th pin of the shadow alarm circuit to Gnd of the arduino.