programming arduino uno

Can anyone send me an example of a sketch for a police bar with 2 red leds and 2 blue leds for a blinking pattern, but not a blink blink .....a nice alternating light bar blinking. Send to dbutler0526@gmail.com

Edit: Since it has been moved, my response no longer applies.

Around here, I've noticed that the state trooper cars employ what is almost a random pattern for flashing their LED's - specifically intended to be unpredictable, catch your eye, and increase safety I'm sure. I've thought that would be a fun programming exercise.

Here is a sketch that randomly blinks some of 4 LED's each cycle. Maybe you can use this as a base.

int randNumber;


void setup()
{

	// pick a seed for random numbers based on analog noise
	
	randomSeed(analogRead(0));


	// initialize the LED output pins 2, 3, 4, and 5
	
	for (int thisPin = 2; thisPin < 6; thisPin++)  

		{
		pinMode(thisPin, OUTPUT);      
		}

}

void loop()
{

	//walk through the pins
	
	for (int thisPin = 2; thisPin < 6; thisPin++) 

		{

		//generate a random number- either 0 or 1

		randNumber = random(0,2);
    
		// if you multiply 0 or 1 by 255 you will get either 0 or 255

		// for an analogWrite, 0 is off and 255 is on
		// write each pin with either a 0 or a 255
		
		analogWrite(thisPin, randNumber * 255);
		}
		
	
	// let them be on for a half a second
		
        delay(500);


	// turn them all off
	
	for (int thisPin = 2; thisPin < 6; thisPin++) 

		{
		analogWrite(thisPin, 0);
		}


	// let them be off for a tiny bit
        
        delay(200);	
	
// go do it again
}

You may want to mess with the timings of the delay to get it just like you want it.

Cheers.

Something similar to this, maybe?

I've since added more "variety" to the pattern, and made the code easy to set up any pattern you'd like.

Let me know.

I've built this circuit up and used this code for someone before
http://nootropicdesign.com/projectlab/2010/01/08/arduino-police-lights/
I used 2 Red LEDs in series for one side, and 2 Blue LEDs in parallel for the other.

I've also made up a single RGB LED sketch on my DigiSpark (ATTiny) w/potentiometer speed control which I think looks pretty decent. The light it throws onto nearby walls makes it look like there's a cop car outside with lights running anyway.

CrossRoads:
I've built this circuit up and used this code for someone before
Arduino Police Lights | Project Lab
I used 2 Red LEDs in series for one side, and 2 Blue LEDs in parallel for the other.

Nice work!
I really like the use of random— gives a great effect. I worked up a quick "version" of your code on my 16 NeoPixel ring from Adafruit. I think I could probably pull someone over with it....if I were that kind of person. :grin: