Police Light Examples with Nerdonic Exen Mini

Description: Below are four examples of blue and red leds flashing in different police light patterns with the Nerdonic Exen Mini.

Police Lights #1 Nerdonic Exen Mini

Supplies:

1 –  Breadboard 400 Points
1 – Nerdonic Exen Mini
8 – LED (Four Blue, Four Red)
1 – 220 Ohm Resistor

Arduino Code (Example 1):

#define led1 A1
#define led2 A2
#define led3 A3
#define led4 A4

#define led5 SCL
#define led6 SDA
#define led7 0
#define led8 1

void setup() {

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);

  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);

}

void loop() {

  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  delay(150);

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  delay(100);

  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  delay(150);

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH);
  digitalWrite(led6, HIGH);
  digitalWrite(led7, HIGH);
  digitalWrite(led8, HIGH);
  delay(150);

  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  delay(100);

  digitalWrite(led5, HIGH);
  digitalWrite(led6, HIGH);
  digitalWrite(led7, HIGH);
  digitalWrite(led8, HIGH);
  delay(150);

}

 

Arduino Code (Example #2):

#define led1 A1
#define led2 A2
#define led3 A3
#define led4 A4

#define led5 SCL
#define led6 SDA
#define led7 0
#define led8 1

void setup() {

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);

  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);

}

void loop() {

  digitalWrite(led1, HIGH);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  delay(150);

  digitalWrite(led1, LOW);
  digitalWrite(led2, HIGH);
  delay(150);

  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
  delay(150);

  digitalWrite(led3, LOW);
  digitalWrite(led4, HIGH);
  delay(150);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH);
  delay(150);

  digitalWrite(led5, LOW);
  digitalWrite(led6, HIGH);
  delay(150);

  digitalWrite(led6, LOW);
  digitalWrite(led7, HIGH);
  delay(150);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  delay(150);

}

 

Arduino Code (Example #3):

#define led1 A1
#define led2 A2
#define led3 A3
#define led4 A4

#define led5 SCL
#define led6 SDA
#define led7 0
#define led8 1

void setup() {

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);

  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);

}

void loop() {

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH);
  digitalWrite(led6, HIGH);
  digitalWrite(led7, HIGH);
  digitalWrite(led8, HIGH);
  delay(500);

  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  delay(500);

}

 

Arduino Code (Example #4):

#define led1 A1
#define led2 A2
#define led3 A3
#define led4 A4

#define led5 SCL
#define led6 SDA
#define led7 0
#define led8 1

void setup() {

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);

  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);

}

void loop() {

// Flash blue lights 3 times

for (int a=1; a<=3; a++) {

  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  delay(75);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  delay(40);

}
delay(80);

// Flash red lights 3 times

for (int a=1; a<=3; a++) {

  digitalWrite(led5, HIGH);
  digitalWrite(led6, HIGH);
  digitalWrite(led7, HIGH);
  digitalWrite(led8, HIGH);
  delay(75);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  delay(40);

}
delay(80);
}

Leave a Comment

− 2 = 2