Introduction: How to Make Flashing Police Lights With Sound

Picture of How to Make Flashing Police Lights With Sound
This is an Instructable on How to make flashing police lights with sound

Heres an example


Before i start the actual tut i just want to say this is my first tutorial, and i also want to say thank you to Dave1324 for your tutorial and also Tom Igoe for the code...

Step 1: You Will Need

Picture of You Will Need

For this project you'll need:
1 Piezo Element
1 Tri-color LED Or 1 Red LED and 1 Blue LED
Some jumper cables
1 Breadboard
1 Arduino or suitably similar thing (I use the arduino Uno) 

Optianal:
Resisters (I dont know the strength needed cause i dont use the for this project)

Step 2: Wirering

Picture of Wirering

Wirering:

1. put your Tricolor LED in your breadboard.
2. run a wire from the led ground to the arduino ground
3. run a wire from the led red to port 9 on the arduino
4. run a wire from the led blue to port 10 on the arduino
5. put your piezo element in the breadboard,
6. run a wire from piezo ground to the row with the led ground
7. run a wire from the positive side of the piezo element to port 11
8. run a wire from the positive side of the piezo element to port 6


Okey thats the wirering done :D

Step 3: The Code

Now assuming you know how to insert and upload the code i am just going to insert it here:


// By Jonas P. Hyatt
// Thanks to Tom Igoe and Dave1324

int ledDelay = 50;
int redPin = 9;
int bluePin = 10;

void setup() {
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void loop() {
digitalWrite(bluePin, LOW);
delay(ledDelay);
digitalWrite(redPin, HIGH);
delay(ledDelay);
digitalWrite(redPin, LOW);
delay(ledDelay);
digitalWrite(redPin, HIGH);
delay(ledDelay);
digitalWrite(redPin, LOW);
delay(ledDelay);
digitalWrite(redPin, HIGH);
delay(ledDelay);

noTone(11);
tone(6, 440, 200);


digitalWrite(redPin, LOW);
delay(ledDelay);
digitalWrite(bluePin, HIGH);
delay(ledDelay);
digitalWrite(bluePin, LOW);
delay(ledDelay);
digitalWrite(bluePin, HIGH);
delay(ledDelay);
digitalWrite(bluePin, LOW);
delay(ledDelay);
digitalWrite(bluePin, HIGH);

noTone(6);
tone(7, 494, 500);

noTone(7);
tone(11, 523, 300);

Comments

Gökay Güllü (author)2016-05-23

You are awesome,thanks mate!

indianSuperman (author)2015-08-12

You said

" 7. run a wire from the positive side of the piezo element to port 11

8. run a wire from the positive side of the piezo element to port 6 "

What's that supposed to mean? I don't understand.

FelixD3 (author)indianSuperman2015-09-03

The figure shows that positive(red wire) is connected to digital pins #6 and 11.

killer1479 (author)2014-01-25

this was cool, thank you for sharing,

made it with my brand new arduino UNO, and it worked first time :D

About This Instructable

33,114views

10favorites

License:

More by Blueray03:Arduino thermometer, LCD Display, ThermistorHow to make flashing police lights with sound
Add instructable to: