A Little Description

Today, we shall make a police siren using nothing other than an RGB light bulb, a force sensor (coz why not), and a seriously annoying little device that will take care of the “siren” part of it. The plan is to measure the amount of force applied on the force sensor and switch to a more rapid flashing lights and siren.

Application

Probably useful for some cop who alternates between a relaxed grip while cruising across the highway to a more firm grip when chasing some poor guy with broken tail lights and other drivers refuse to give way.

Resources

The first step in the process to gather the various items needed to complete this build. Below are a list of parts used:

  • 1x Arduino UNO R3
  • 1x Half+ Breadboard
  • 10x Assorted Jumper Wires
  • 1x Piezo Speaker (Buzzer)
  • 1x Force Sensor
  • 1x 10KΩ Resistor
  • 1x RGB LED
  • 3x 220Ω Resistor

Design

I used a little open source program called Fritzing to assist me with developing a sketch in order to illustrate the connections. The resulting wiring diagram makes it super simple for anyone to follow along and try it for themselves.

Assembly

Once the diagram is made, we can begin assembling the components onto the breadboard and making links between the Arduino and components.

1| Power and Ground
The very first step is to connect the 5V power to the positive line on the board using a red jumper wire and the ground to the negative line using a black wire.

2| Wiring the RGB LED
Grab an RGB LED and connect it to the breadboard. The wires are generally arranged in the following order: Red, Ground, Green, Blue. Connect a wire from the ground pin to the grounded line on the breadboard. Grab three more jumper wires and connect each of the reg, green and blue pins to a digital header on the board. Then take three 220Ω resistors and place them in between the three LED pins and their respective jumper wires.

3| Wiring the Buzzer
Plug the piezo speaker onto the breadboard and take a black jumper wire from the negative pin to the negative line on the breadboard. Following that step, add jumper wires from the positive pin on the speaker to a digital pin on the Arduino.

4| May the Force be with You
The force sensor wiring is a little different to the other ones as it uses analog pins on the board instead of digital. To wire it up, a jumper cable from the right pin can be taken to any of the analog inputs. A 10KΩ resistor can be placed across the jumper wire grounding the right pin. Lastly, a jumper wire should connect the left pin to the 5v power line.

5| Ensure Correct Connections are Made
The very last and most crucial step is to ensure all connections are made property and accurately. The last thing you want is a bunch of damaged electronics. Although we are working with low powered components, it is good practise to always double check.

Code

To write the code, I made use of the Arduino software to write the code. I started off by declaring the variables for the components and their respective pins. I then assigned the digital components as outputs in the setup. I then set a light and sound pattern when the force sensor value is under a certain amount, and a different pattern the remainder of the time.

/* CODE BY RAHUL PRABHUDESAI */

const int forceSensor = A0;
int sensorValue = 0;
const int LEDr = 3;
const int LEDg = 5;
const int LEDb = 6;
const int buzzer = 10;

void setup() {
  Serial.begin(9600);
  pinMode(LEDr, OUTPUT);
  pinMode(LEDg, OUTPUT);
  pinMode(LEDb, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  sensorValue = analogRead(forceSensor); // read the analog in value

  // print the results to the serial monitor:
  Serial.print("sensor = ");
  Serial.println(sensorValue);

  if (sensorValue < 1023) {  
    digitalWrite(LEDr, LOW);
    digitalWrite(LEDg, LOW);
    digitalWrite(LEDb, HIGH);
    tone(buzzer, 500);
    delay(100);
    digitalWrite(LEDr, HIGH);
    digitalWrite(LEDg, LOW);
    digitalWrite(LEDb, LOW);
    tone(buzzer, 1000);
    delay(100);
  }
  else {
    digitalWrite(LEDr, LOW);
    digitalWrite(LEDg, LOW);
    digitalWrite(LEDb, HIGH);
    tone(buzzer, 500);
    delay(1700);
    digitalWrite(LEDr, HIGH);
    digitalWrite(LEDg, LOW);
    digitalWrite(LEDb, LOW);
    tone(buzzer, 1000);
    delay(1700);
  }
  
}

Result

Below is a video of the finished product.

Final Thoughts

My final thoughts is this turned our fairly well and was an enjoyable experience. It would be nice to better match the tone of a real police siren along with the delay between red and blue light transitions during the two modes.