loading
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

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

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);

<p>You are awesome,thanks mate!</p>
<p>You said </p><p>&quot; 7. run a wire from the positive side of the piezo element to port 11</p><p>8. run a wire from the positive side of the piezo element to port 6 &quot;</p><p>What's that supposed to mean? I don't understand.</p>
<p>The figure shows that positive(red wire) is connected to digital pins #6 and 11.</p>
<p>this was cool, thank you for sharing, </p><p>made it with my brand new arduino UNO, and it worked first time :D</p>

About This Instructable

30,441views

10favorites

License:

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