Introduction: Arduino (101) Based - Police Sequence Bar

Picture of Arduino (101) Based - Police Sequence Bar

Very simple flashing police sequence bar mock-up.

NOTE: I will not be responsible for anyone trying to impersonate police. Please use this as a fun experiment only! I find the flashing mesmerizing in a very sort of strange way.

Here is an example:

https://circuits.io/circuits/2575181-police-lights

The code:

/*

Name: PoliceLights.ino

Created: 8/17/2016 5:36:59 PM

Author: William Daugherty II

*/

// the setup function runs once when you press reset or power the board

int i = 40;

void setup()

{

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

}

// the loop function runs over and over again until power down or reset

void loop()

{

Play1();

Play1();

Play1();

Play2();

Play2();

Play2();

Play1();

Play1();

Play1();

Play2();

Play2();

Play2();

Play1();

Play1();

Play1();

Play2();

Play2();

Play2();

Play1();

Play1();

Play1();

Play2();

Play2();

Play2();

Play1();

Play1();

Play1();

Play3();

Play3();

Play3();

Play4();

Play4();

Play4();

Play3();

Play3();

Play3();

Play4();

Play4();

Play4();

Play3();

Play3();

Play3();

Play4();

Play4();

Play4();

Play3();

Play3();

Play3();

Play4();

Play4();

Play4();

Play3();

Play3();

Play3();

Play4();

Play4();

Play4();

}

void Play0()

{

delay(i);

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

digitalWrite(7, LOW);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

}

void Play1()

{

Play0();

delay(i);

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

}

void Play2()

{

Play0();

delay(i);

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

digitalWrite(4, HIGH);

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

digitalWrite(7, LOW);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

}

void Play3()

{

Play0();

delay(i);

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

}

void Play4()

{

Play0();

delay(i);

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

digitalWrite(4, LOW);

digitalWrite(5, LOW);

digitalWrite(6, HIGH);

digitalWrite(7, HIGH);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

}

Comments

tomatoskins (author)2016-08-18

This looks great!

About This Instructable

888views

13favorites

License:

More by BillD96:Arduino (101) Based - Police Sequence Bar
Add instructable to: