Guest User

Untitled

a guest
Jul 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. int ledpin=16;
  2. int irpin =5;
  3. int buzzerpin=4;
  4.  
  5. void setup()
  6. {
  7. Serial.begin(9600);
  8. pinMode(ledpin, OUTPUT); //voltage for LED
  9. pinMode(irpin, INPUT); // recieve data from ir sensor
  10. pinMode(buzzerpin, OUTPUT); //Give value to buzzer
  11.  
  12. }
  13.  
  14. void loop()
  15. {
  16. digitalWrite(buzzerpin,0); //buzzer should get value 0 by default. The case of no intrusion
  17. int intensity=analogRead(A0); // read the intensity of light in the room
  18. analogWrite(ledpin,intensity);
  19. if(digitalRead(irpin)==0){
  20. digitalWrite(buzzerpin,1); // Case of intrusion
  21. delay(1000); // time for which buzzer is ON
  22. }
  23.  
  24. delay(500);
  25.  
  26. }
Add Comment
Please, Sign In to add comment