Devices & Components
Arduino Uno Rev3
LED (generic)
Buzzer
Breadboard (generic)
Pushbutton switch 12mm
PIR Sensor, 7 m
Male/Female Jumper Wires
Resistor 220 ohm
Software & Tools
Arduino IDE
Project description
Code
CODE;
c_cpp
1//this project is made by BEASTIDREES62 https://id.arduino.cc/?code=MTxqeHweG6vL2cur&state=amxEcTB2bnNiYjluTUxmRExWaWZnOXIzUk1BLWRqZTZYUGtJNGtxODB%2Bdg%3D%3D 2// Declaring Pins 3const int buzzerPin = 5; 4const int ledPin = 6; 5const int motionPin = 7; 6const int buttonPin = 12; 7 8// Setting Buzzer mode to False 9boolean buzzer_mode = false; 10 11// For LED 12int ledState = LOW; 13long previousMillis = 0; 14long interval = 100; // Interval at which LED blinks 15 16void setup() 17{ 18 //The Following are our output 19 pinMode(ledPin,OUTPUT); 20 pinMode(buzzerPin,OUTPUT); 21 22 //Button is our Input 23 pinMode(buttonPin, INPUT); 24 25 // Wait before starting the alarm 26 delay(5000); 27} 28 29void loop() 30{ 31 // To chech whether the motion is detected or not 32 if (digitalRead(motionPin)) { 33 buzzer_mode = true; 34 } 35 36 // If alarm mode is on,blink our LED 37 if (buzzer_mode){ 38 unsigned long currentMillis = millis(); 39 if(currentMillis - previousMillis > interval) { 40 previousMillis = currentMillis; 41 if (ledState == LOW) 42 ledState = HIGH; 43 else 44 ledState = LOW; 45 // Switch the LED 46 digitalWrite(ledPin, ledState); 47 } 48 tone(buzzerPin,1000); 49 } 50 51 // If alarm is off 52 if (buzzer_mode == false) { 53 54 // No tone & LED off 55 noTone(buzzerPin); 56 digitalWrite(ledPin, LOW); 57 } 58 59 // If our button is pressed Switch off ringing and Setup 60 int button_state = digitalRead(buttonPin); 61 if (button_state) {buzzer_mode = false;} 62}
CODE;
c_cpp
1//this project is made by BEASTIDREES62 https://id.arduino.cc/?code=MTxqeHweG6vL2cur&state=amxEcTB2bnNiYjluTUxmRExWaWZnOXIzUk1BLWRqZTZYUGtJNGtxODB%2Bdg%3D%3D 2// Declaring Pins 3const int buzzerPin = 5; 4const int ledPin = 6; 5const int motionPin = 7; 6const int buttonPin = 12; 7 8// Setting Buzzer mode to False 9boolean buzzer_mode = false; 10 11// For LED 12int ledState = LOW; 13long previousMillis = 0; 14long interval = 100; // Interval at which LED blinks 15 16void setup() 17{ 18 //The Following are our output 19 pinMode(ledPin,OUTPUT); 20 pinMode(buzzerPin,OUTPUT); 21 22 //Button is our Input 23 pinMode(buttonPin, INPUT); 24 25 // Wait before starting the alarm 26 delay(5000); 27} 28 29void loop() 30{ 31 // To chech whether the motion is detected or not 32 if (digitalRead(motionPin)) { 33 buzzer_mode = true; 34 } 35 36 // If alarm mode is on,blink our LED 37 if (buzzer_mode){ 38 unsigned long currentMillis = millis(); 39 if(currentMillis - previousMillis > interval) { 40 previousMillis = currentMillis; 41 if (ledState == LOW) 42 ledState = HIGH; 43 else 44 ledState = LOW; 45 // Switch the LED 46 digitalWrite(ledPin, ledState); 47 } 48 tone(buzzerPin,1000); 49 } 50 51 // If alarm is off 52 if (buzzer_mode == false) { 53 54 // No tone & LED off 55 noTone(buzzerPin); 56 digitalWrite(ledPin, LOW); 57 } 58 59 // If our button is pressed Switch off ringing and Setup 60 int button_state = digitalRead(buttonPin); 61 if (button_state) {buzzer_mode = false;} 62}
Downloadable files
Schematics of this projects
Schematics of this projects
Comments
Only logged in users can leave comments