Arduino Alarm/Ring System

Recently, I've been learning about how Arduinos and circuits and wanted to use some more complicated components than what I had been using. I got the idea from my ring doorbell and how it responds when it detects motion, so I found the parts in the kit I had gotten and decided to make something as similar as possible without the some of the components like a camera. Overall, it's a relatively simple circuit but it definitely can be expanded into some really cool projects.
Supplies
For this project, I got the ELEGOO most complete starter kit from Amazon:
Once you have that, from the kit you'll need -
1x UNO R3 Arduino board
1x bread board
1x PIR motion sensor
4x 100 Ohm resistors
1x Active buzzer
1x green LED
1x red LED
10x beard board cables (varying sizes)
Wiring Your Circuit


By following the schematic, you will be able to mostly get the entire circuit completely wired correctly. However, it's super important to note the PIR pins on Tinkercad (what I used to draw the circuit out) is different from the PIR that comes with the Arduino kit. You'll want your pin closest to the mode switch to be ground voltage, middle pin as the signal wire, then the right wire to send power from the 5V pin on the Arduino UNO R3. Lastly, an important hardware thing to note is that you will want to switch the mode on your PIR motion sensor from H-mode to I-mode, as it will allow you to execute the alarm for however long there is motion that is being picked up on. You do this by taking the yellow thing of those pins and shifting it up.
Adding the Code

You'll need to have the Arduino IDE, and you can get it for free here.
Feel free to adjust any of the pins or values depending on how you'd like or to what works for your board.
int ledPin = 4; // red pin
int ledPin2 = 5; //green pin
int pirSensorPin = 2; //motion sensor
int buzzerPin =6;
int motionDetected = LOW; // intialize
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(pirSensorPin, INPUT);
Serial.begin(9600);
Serial.println("Starting Now");
delay(1000);
}
void loop() {
digitalWrite(ledPin2, HIGH);
motionDetected = digitalRead(pirSensorPin);
while(motionDetected == HIGH)
{
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, LOW);
digitalWrite(buzzerPin, HIGH);
delay(100); //adjust these for better flashing
digitalWrite(ledPin, LOW);
delay(100); // adjust for more flashes
motionDetected = digitalRead(pirSensorPin); // this will break the loop
}
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, HIGH);
digitalWrite(buzzerPin, LOW);
}
Test It Out!
Sometimes the motion sensor takes a few seconds to change from the on/off position so it's probably best to wait a few seconds after each trigger to get the best response time each trial you do. I hope you enjoyed this little project and get to create it for yourself!