loading

This was one of the first programs i wrote for the arduino after having it a few days :)

we will be making l.e.d police lights with minimal materials




Step 1: You will need.

You will need

Arduino (or suitable clone)
Breadboard
2x 240ohm resistors
1x Clear Red l.e.d
1x Clear Blue l.e.d
Some Jumper Cables
<p>If you use the code from above you will need to take out the colon before the LOW at about the 6th digitalWrite. digitalWrite(redPin, (needs to be deleted)<strong> :</strong>LOW); // turn the red light off </p>
<p>Thanks, this helped me solve the error that happened when I copy-pasted the original code.</p>
<p>Nice project. I will try to make another, like you. I like the way flicker. Some time ago I also did something similar: https://www.youtube.com/watch?v=obikRkdssaE</p>
<p>i have just tried to make it but it doesnt work .i uploaded the sketch and that was successful.but the led lights are not working</p>
<p>can i do with arduino uno?</p>
<p>Arduino: 1.6.0 (Windows 8), Board: &quot;Arduino Uno&quot;</p><p>sketch_feb25h.ino: In function 'void loop()':</p><p>sketch_feb25h.ino:29:22: error: expected primary-expression before ':' token</p><p>Error compiling.</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
<p>//Most interactive police lights. I reccommend this code.</p><p>int yarkost = 50; //The brightness of the LEDs. From 0 to 255</p><p>int on_leds[] = {3, 9}; //The pins, which are connected to the LEDs</p><p>void setup() {</p><p> randomSeed(analogRead(0)); initialization of randomize</p><p>}</p><p>void loop() {</p><p>delay(100); <br></p><p>int red_cy = random(1, 4);</p><p>for(int i = 0; i &lt; red_cy; i++){</p><p>analogWrite(on_leds[0], yarkost);</p><p>delay(70);</p><p>analogWrite(on_leds[0], 0);</p><p>delay(50);</p><p>}</p><p>delay(random(50,100));</p><p>int blue_cy = random(1, 4);</p><p>for(int i = 1; i &lt;= blue_cy; i++){</p><p>analogWrite(on_leds[1], yarkost);</p><p>delay(70);</p><p>analogWrite(on_leds[1], 0);</p><p>delay(50);</p><p>}</p>
<p>You can simplify the code:</p><p>void police()</p><p>{</p><p> for(int i = 0; i &lt; 6; i++){</p><p> analogWrite(on_leds[2], yarkost); // turn the red light on</p><p> delay(50); // wait 50 ms</p><p> analogWrite(on_leds[2], 0);</p><p> }</p><p> delay(50);</p><p> for(int i = 0; i &lt; 6; i++){</p><p> analogWrite(on_leds[3], yarkost); // turn the red light on</p><p> delay(50); // wait 50 ms</p><p> analogWrite(on_leds[3], 0);</p><p>}</p><p>}</p>
This is great! I'm using it to make strobe lights for plowing. So instead of using the resistors and leds I'm using dc to dc solid state relays. those will make the cab marker lights on my truck and 3 interior mounted window lights flash. I just tested it on my test bench and it worked great.... THANKS! Also how would I make this sequence start when I push a momentary button connected to the arduino? or make them stay on if I pushed a different button? what would the code be?
I found a slight error in the code. Pretty easy to fix, but a total n00b may not know where it is....<br> <br> [quoted code]<br> digitalWrite<strong>(redPin, :LOW)</strong>; // turn the red light off<br> delay(ledDelay); // wait 50 ms<br> delay(100); // delay midpoint by 100ms<br> [/quoted code]<br> <br> Basically, take out the : from before the LOW command. ;)<br> Other than that, my young boy loves the lights, thanks.<br> <br> -KegRaider
Great instrucable. I'm working on an emergency led lighting system, so this comes in handy.<br><br>One thing I would suggest for a smoother pattern, is to add another delay of 100ms at the end of your loop.<br><br>Right now it loops from blue-off to red-on without a delay, but the opposite has the 100ms delay at the midpoint. Adding that same midpoint delay at the end will make everything balance out.
I have been researching flash patterns to use with my Arduino, and I have found that this works fairly good: <br> <br>-Red flashes 3 times (50ms on, 50ms off) <br>-Blue flashes 3 times (50ms on, 50ms off) <br>-Alternating flashes of each (back and forth)
I have been researching flash patterns to use with my Arduino, and I have found that this works fairly good: <br> <br>-Red flashes 3 times (50ms on, 50ms off) <br>-Blue flashes 3 times (50ms on, 50ms off) <br>-Alternating flashes of each (back and forth)
it's very cool simple effect :) thanks ;]

About This Instructable

36,724views

39favorites

License:

More by dave1324:Simple Arduino L.E.D Police Lights 
Add instructable to: