Introduction: How to Make Arduino Police Lights
Required items:
Arduino (any kind)
Computer to program Arduino
8 LED's (preferrably high intensity blue and red)
22AWG Wire for the Breadboard
7 100ohm resistors (pin 13 does not need a resistor on the Duemilanove)
(optional) Breadboard to make connections easier
The lights in action.
Step 1: Connecting the Wires
Step one: Connect the wires.
Connect a wire from pins 13, 12, 11, 10, 9, 8, 7, and 6 from your Arduino and plug them into the breadboard.
Next, take your LED's and take the wires from your Arduino and plug each wire into each anode of each LED.
My Arduino is a Duemilanove which has a resistor built into pin 13. I'm not sure about different models, but to be safe I would add one anyway. Next, hook up a 100ohm resistor to each ANODE (which is the longer leg) of each LED and for the shorter leg, it goes to the ground of your Arduino.
You're done with the physical aspect of it! Now onto the code!
Step 2: The Code
The code is as follows. Just paste this into the Arduino environment, compile it and upload it:
*/ This is the code for police lights using an Arduino. This will make the left side blink twice and then the right side blink twice. You can change the value of "delay()" from 1 to infinity. The number is in milliseconds, and there are 1000 milliseconds in a second. I found 50ms is pretty good.
/*
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
delay(50); //You can make the lights change speed by changing this value.
digitalWrite(13, LOW); //It is in milliseconds and there are 1000 milliseconds in a second.
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
delay(50);
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
delay(50);
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
delay(50);
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
delay(50);
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
delay(50);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
delay(50);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
delay(50);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
delay(50);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
delay(50);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
delay(50);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
delay(50)
}
Step 3: Somewhat Related Notes
Like I stated earlier, on the Duemilanove, there is already an LED on pin 13, along with a resistor so an LED can use that pin. I found out from someone on the internet (I don't remember whom) but they said a 100ohm resistor is optimal for 5-6v. Some color LED's use more or less voltage/current so you can use this website to figure out which resistor to use (and it draws a schematic for you!) http://ledcalc.com/
I have one question, anyone that can answer this will become immortal. When I hook up my LED's to the Arduino's ground pin(s) they work when powered by the Arduino. I have my Arduino hooked up to 4 AA batteries giving out ~6v into the 2.1mm jack on my Arduino. When I have the LED's powered by my Arduino, and hook the cathodes to the ground of my batteries, the LED's don't work. My question is why. Shouldn't all grounds be the same? The power is going back into the batteries anyway. Maybe it's a voltage regulator because I've heard they need ground hooked up to them also.
Here is how to do this with an Arduino MEGA 2650:
https://www.instructables.com/id/Arduino-Police-Lights-ATMega-2650-Version/
5 Comments
12 years ago on Introduction
The resistors are used to limit the amount of current passing through the LED to protect it from burning itself up. Left to itself a LED will glow very brightly and then croak. When you place the resistor in line with the LED, either before or after the junction where the light is coming from, it limits how much current can flow back to ground. Cool instructable, Thanks!
6 years ago
can i use arduino promini?
7 years ago
Hi, i'm looking for a circuit that makes lights like Chicago PD's. Do you know of any?
10 years ago on Introduction
When doing any project you should make sure all ground are connected. Wish I could tell you more.
12 years ago on Introduction
If the LED draws too much current, the internal driver of the Arduino - Atmel 328 chip will be blown. Check the specs for current output of the Atmel pins, if they are less than the current required by the LED then, a simple transistor switch is needed to control the LED. The size of the transistor depends on the amount of current required by the LED, you will still also need a limiting resistor to limit the current to the LED. The base of the transistor would then be connected to the Arduino via a 2K resistor to limit current to the transistor base. The resistor also acts as a buffer between Atmel 328 and the transistor. Hope this helps.