Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ledpin=16;
- int irpin =5;
- int buzzerpin=4;
- void setup()
- {
- Serial.begin(9600);
- pinMode(ledpin, OUTPUT); //voltage for LED
- pinMode(irpin, INPUT); // recieve data from ir sensor
- pinMode(buzzerpin, OUTPUT); //Give value to buzzer
- }
- void loop()
- {
- digitalWrite(buzzerpin,0); //buzzer should get value 0 by default. The case of no intrusion
- int intensity=analogRead(A0); // read the intensity of light in the room
- analogWrite(ledpin,intensity);
- if(digitalRead(irpin)==0){
- digitalWrite(buzzerpin,1); // Case of intrusion
- delay(1000); // time for which buzzer is ON
- }
- delay(500);
- }
Add Comment
Please, Sign In to add comment