Police Siren Circuit
This project is a police siren system that uses a distance sensor, LEDs, and a speaker. The circuit is connected to an Arduino Uno, which controls how fast the LEDs rotate and how quickly the speaker produces the siren sound when a button is pressed.
An ultrasonic sensor is also included to detect how close my hand is to the sensor. As my hand gets closer, the siren sound speeds up and the LEDs flicker faster. This mimics how real police lights and sirens become more intense during an emergency to signal cars ahead to move out of the way.
Supplies
4- 330 resistors
1- RED led
1- BLUE led
1- pushbutton
1- speaker
1- ultrasonic sensor
1- Arduino Uno
1- Wire
1- Wirestripper
several male to male wires to make connections
Parts & Prices
Resistors
4 × 330 Ω resistors
• 330 Ohm Resistors Pack – ~$9.11 (multiple included)
LEDs
1 × Red LED
• Red 5mm LED (100 pcs) – ~$8.99 (bulk pack)
1 × Blue LED
• Blue LEDs Pack – ~$11.00 (multiple included)
Pushbutton
• Push Button Switch – ~$12.19 (bulk pack)
Speaker / Buzzer
• Beep Speaker (Pack) – ~$9.78
(small breadboard-friendly speaker/buzzer works well in Arduino projects)
Ultrasonic Distance Sensor
• HC‑SR04 Ultrasonic Sensor – ~$2.00
Arduino Board
• Arduino UNO Rev3 – ~$38.99
Breadboard – ~$12.99 (comes in 3)
Wires
Male-to-Male Jumper Wires (for breadboard connections)
• 40‑Pin Male‑Male Jumper Wires – ~$7.99
Wire Stripper / Cutter
• Wire Stripper Tool – ~$24.68
Hookup Wire (for the long wires which will be connected to the Arduino uno)
• 100 solid copper hook-up wire – ~$17.52
Those are the prices of all the pieces you will need (some come in bulk) which will be perfect for future projects.
Connect All Components to the Breadboard
Start by gathering all your supplies and separate them from each other, once you have done that connect a push button across the middle gap.
PUSH BUTTON CONNECTIONS
-connect a 330 resistor to one end of the button, while connecting the other end of the resistor to GND(negative)
-than connect a wire parallel to the resistor and connect one end of the wire to the push button while connecting the other end to GND (positive)
BOTH LED CONNECTIONS
Once you have done that now get a resistor and connect one side to GND (negative) while placing the other one to the bottom leg of your led
-take your led and make it go across the middle and connect it around the middle of the other section
-take your blue led now(preferably attach one leg of the led to a resistor using soldering) and connect the leg with the resistor attached to GND (negative)
-after you have done this leave them and do not try taking a wire and connecting them together as we will in the future connect the remaining legs of the leds to a wire leading it to the Arduino UNO
-make sure there is a gap between your push button and both of your leds
SPEAKER CONNECTIONS
Once you have done both led connections now attach a speaker across the middle gap of the breadboard
-now connect a resistor to the speaker
-ensure that the smaller leg of the speaker is connected to the resistor
-Leave the longer leg of the speaker as it will be connected to the arduino
ULTRASONIC SENSOR CONNECTIONS
-Simply separate the ultrasonic sensor from the other components on the breadboard and place it anywhere you prefer
-leave all parts (vcc,gnd,5v etc) unattached by wires as once again these will be added via Arduino
Arduino Uno Wiring
Now it is time to wire everything to the Arduino but before that ensure you have a wire that can connect to the Arduino and be connected to a usb port
Once your Arduino is powered up start by making the button connections
BUTTON WIRING
-across the resistor add a long wire so that it can reach the Arduino, connect this button pin to GND
-across the wire which was originally connected parallel to the resistor add another long wire and connect this to pin #2
LED WIRING
-Now take another long wire and connect it to the end of the blue led where it is not attached to anything else (so not next GND) and connect that to Arduino Uno pin 12
-Now take another long wire and connect that to the unattended end of the red led, and connect that wire to the Arduino Uno at pin #13
SPEAKER WIRING
-take another long wire and attach one end to the unattended pin on the breadboard to Arduino Uno pin #9
Ultrasonic WIRING
VCC-5V
GND-GND
TRIG-7
ECHO-8
CODE
To make this circuit work after connecting all the wires install the Arduino app, once it is installed enter this code and make sure the program is selected to Arduino uno and that your port is connected to the Arduino it self
CODE
const int button Pin = 2;
const int ledPin1 = 13;
const int ledPin2 = 12;
const int speakerPin = 9;
// --- Ultrasonic Sensor Pins ---
const int trigPin = 7;
const int echoPin = 8;
// -----------------------------
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(speakerPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
// --- Ultrasonic Setup ---
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600); // For debugging
}
void loop() {
if (digitalRead(buttonPin) == LOW) {
playSiren();
} else {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
noTone(speakerPin);
}
}
// Function to measure distance in cm
long getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
// Calculate distance in cm
return duration * 0.034 / 2;
}
void playSiren() {
// Get distance
long distance = getDistance();
Serial.println(distance); // Optional debugging
// Determine volume based on distance (close = louder)
// If closer than 10cm, no delay (full sound). Otherwise, add intermittent silence.
int silentTime = (distance < 10) ? 0 : 5;
// --- Siren Logic (Unchanged except for tone frequency control) ---
// Rising frequency
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
for (int freq = 440; freq < 1000; freq += 2) {
tone(speakerPin, freq);
delay(2);
if (silentTime > 0) { noTone(speakerPin); delay(silentTime); } // Volume control
}
// Falling frequency
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
for (int freq = 1000; freq > 440; freq -= 2) {
tone(speakerPin, freq);
delay(2);
if (silentTime > 0) { noTone(speakerPin); delay(silentTime); } // Volume control
}
}
Recheck Connections
Make sure all the connections follow the ones listed above, make sure all wires are fully connected and are not overflowing.
While making this project I occurred many problems with the leds and most of the time I had to switch polarity's multiple times and double check wires very frequently. If you feel the code is doing another function than it is designed to do, you can always modify the given code with small tweaks to where the pin assignments may be or what you may want the code too do.
You may also face problems such as
-Shortening LEDS
-Connecting to wrong Arduino pins
-Shortened Arduino
-Shortened buttons
and many more and the simple fix to all of these problems is to simply change the component with another identical one, all the links to the components used have links where most of the components come in bulk, this will help incase if one of your leds may be shortened.
Video Explainaton
THIS VIDEO WILL GIVE A ROUGH EXPLAINATION OF HOW THE CIRCUIT WOTRKS: