Arduino Controlled Security Lights Also Scary Prop for Halloween
by Abhinandan pal in Circuits > Arduino
2934 Views, 19 Favorites, 0 Comments
Arduino Controlled Security Lights Also Scary Prop for Halloween
![5624ea0515be4d491d0004f3.jpeg](/proxy/?url=https://content.instructables.com/FJY/HY3X/IFWRP832/FJYHY3XIFWRP832.jpg&filename=5624ea0515be4d491d0004f3.jpeg)
![MOV 0000028](/proxy/?url=https://content.instructables.com/FV3/S95P/IFWRP8E9/FV3S95PIFWRP8E9.jpg&filename=MOV 0000028)
![security light](/proxy/?url=https://content.instructables.com/FPL/SMNM/IFWRP8F0/FPLSMNMIFWRP8F0.jpg&filename=security light)
If you are lost in a jungle and don't know what to do to notify you about an animal and like i wold do you took your arduino kit then this is a ultrasonic oject ditector which will tell you about any animal near......
Materials Required
![arduinouno_r3_front.jpg](/proxy/?url=https://content.instructables.com/FK5/AJJE/IFSHESZR/FK5AJJEIFSHESZR.jpg&filename=arduinouno_r3_front.jpg)
![DSC_0000078.jpg](/proxy/?url=https://content.instructables.com/F2C/0H93/IFSHESV2/F2C0H93IFSHESV2.jpg&filename=DSC_0000078.jpg)
![buzzer.jpg](/proxy/?url=https://content.instructables.com/F5M/0WOQ/IFSHESZW/F5M0WOQIFSHESZW.jpg&filename=buzzer.jpg)
![LED3_2MA.png](/proxy/?url=https://content.instructables.com/FJP/HTU3/IFSHET23/FJPHTU3IFSHET23.png&filename=LED3_2MA.png)
![Momentary_Switch.jpg](/proxy/?url=https://content.instructables.com/FAD/54Q7/IFSHET28/FAD54Q7IFSHET28.jpg&filename=Momentary_Switch.jpg)
![bread.jpg](/proxy/?url=https://content.instructables.com/F53/C76E/IFSHETYG/F53C76EIFSHETYG.jpg&filename=bread.jpg)
![jumper.jpg](/proxy/?url=https://content.instructables.com/FOI/A3E7/IFSHEVQC/FOIA3E7IFSHEVQC.jpg&filename=jumper.jpg)
The stuffs required are
- arduino
- buzzer(local shop)
- led(local shop)
- switch(local shop)
- bread board
- jumper wire( male to male)
- resistors(according to the leds used)
Connect the Main Parts
![DSC_0000082.jpg](/proxy/?url=https://content.instructables.com/F38/TXRA/IFSHETB6/F38TXRAIFSHETB6.jpg&filename=DSC_0000082.jpg)
![DSC_0000085.jpg](/proxy/?url=https://content.instructables.com/FSS/Q3JV/IFSHETFF/FSSQ3JVIFSHETFF.jpg&filename=DSC_0000085.jpg)
![DSC_0000079.jpg](/proxy/?url=https://content.instructables.com/FGN/EIOA/IFSHESV4/FGNEIOAIFSHESV4.jpg&filename=DSC_0000079.jpg)
![DSC_0000087.jpg](/proxy/?url=https://content.instructables.com/FLH/RW97/IFSHETFG/FLHRW97IFSHETFG.jpg&filename=DSC_0000087.jpg)
![DSC_0000088.jpg](/proxy/?url=https://content.instructables.com/FSK/B4P8/IFSHETFI/FSKB4P8IFSHETFI.jpg&filename=DSC_0000088.jpg)
- connect the switch in the middle as shown
- connect the led so that they have a common ground keep a pin gap between two leds use 2 green, 2 yellow,4 red.
- connect the buzzer as shown
- connect the proximity sensor according to the pins
Wiring
![abhi_alarm_system.png](/proxy/?url=https://content.instructables.com/FCR/PSBJ/IFWRP7CK/FCRPSBJIFWRP7CK.png&filename=abhi_alarm_system.png)
![DSC_0000089.jpg](/proxy/?url=https://content.instructables.com/FKN/J4E3/IFSHETFX/FKNJ4E3IFSHETFX.jpg&filename=DSC_0000089.jpg)
![DSC_0000091.jpg](/proxy/?url=https://content.instructables.com/F99/EQQR/IFSHETGC/F99EQQRIFSHETGC.jpg&filename=DSC_0000091.jpg)
![MOV 0000021](/proxy/?url=https://content.instructables.com/FC2/WNIJ/IFWRP8DW/FC2WNIJIFWRP8DW.jpg&filename=MOV 0000021)
wire it according to the image....... or according the video......
![arduino editor.png](/proxy/?url=https://content.instructables.com/FUI/AEGL/IFWRP817/FUIAEGLIFWRP817.png&filename=arduino editor.png)
#define trig 12
#define echo 13
#define power_pin 11
#define buzzerReset A0
#define buzzer 10
int ledS[] = {2,3,4,5,6,7,8,A1};boolean alarmTrig = false;
boolean ledFlash = false; void setup()
{ Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
pinMode(power_pin,OUTPUT);
pinMode(buzzerReset , INPUT);
pinMode(buzzer , OUTPUT);
digitalWrite(power_pin,HIGH); // As because there is no external power source so we need the pin 1 as HIGH
for(int i=0;i<8;i++)
pinMode(ledS[i] , OUTPUT);
} void loop()
{
double distance = hc_sr04(trig, echo); // calls hc_sr04() and get the distance form it
Serial.print(distance); // print the distance Serial.println("cms ahead"); int indicate = map(constrain(distance , 1,20) , 1 , 20 , 0 , 8);
if(ledFlash == false)
{
for(int i = 0 ; i<=indicate ; i++) {
digitalWrite(ledS[i] , LOW);
}
for(int i=indicate ; i<=8 ; i++)
{
if(i == 0)
alarmTrig = true;
digitalWrite(ledS[i] , HIGH);
}
} if(alarmTrig == true)
{
activate_alarm();
}
if(digitalRead(buzzerReset) == HIGH)
resetBuzzer(); } void resetBuzzer()
{ alarmTrig = false;
ledFlash = false;
digitalWrite(buzzer , LOW);
}
double hc_sr04(double trigPin , double echoPin)
{
double duration, distance; // This procedure is mentioned in the datasheet of HC-SR04 attached
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); //Check out the refernce to know about this function......select "pulseIn"
then press Ctrl + Shift + F
distance = ((duration/1000000)*33000)/2; // distance = speed * time/2
return constrain(distance,0,200); // dont know what constrain is just select it and Ctrl + Shift + F
}
void activate_alarm()
{ ledFlash = true; analogWrite(buzzer, 255);
for(int i=0;i<8;i++)
digitalWrite(ledS[i] , HIGH);
delay(100); analogWrite(buzzer , 150);
for(int i=0;i<8;i++)
digitalWrite(ledS[i] , LOW);
delay(100);
}