Police light using arduino nano

In this tutorial, we are going to make a police light using Arduino nano. This project is based on the concept of led blinking. Police light is a good beginner project to understand how microcontrollers work with simple programs.

The components required to make this project are

  1. Arduino nano / uno
  2. 2 x blue led
  3. 2 x red led
  4. 220-ohm resistor
  5. Breadboard
  6. Jumper wires

As long as your desktop is connected to Arduino through cable. we don’t need any external power supply for Arduino.

Connection

Connect the pins of Arduino with the led as mentioned in the table below

Arduino pins

Led pins

 

 

D9

Blue led 1 +ve

D10

Blue led 2 +ve

D11

Red led 1 +ve

D12

Red led 2 +ve

Gnd

-ve of all led’s

Arduino code for police light using arduino nano

The code for police light using Arduino nano is given below with an explanation in the comments.

void setup()  // setup code

{

pinMode (9,OUTPUT);  // declaring pin D9 for output mode

pinMode (10,OUTPUT); // declaring pin D10 for output mode

pinMode (11,OUTPUT); // declaring pin D11 for output mode

pinMode (12,OUTPUT); // declaring pin D12 for output mode

}

 

void loop()  // to run code repeatedly

{

digitalWrite(9,HIGH);  // Putting pin D9 high, led connected to D9 will glow.

digitalWrite(10,HIGH); // Putting pin D10 high, led connected to D10 will glow.

 

delay(1000);  // delay code for 1 second

 

digitalWrite(9,LOW);   // Putting pin D9 low, led connected to D9 will off.

digitalWrite(10,LOW);  // Putting pin D10 low, led connected to D10 will off.

 

digitalWrite(11,HIGH); // Putting pin D11 high, led connected to D11 will glow.

digitalWrite(12,HIGH); // Putting pin D9 high, led connected to D12 will glow.

 

delay(1000);  // delay code for 1 second

 

digitalWrite(11,LOW);  // Putting pin D11 low, led connected to D9 will off.

digitalWrite(12,LOW);  // Putting pin D12 low, led connected to D9 will off.

}

More led can be put in parallel for a single pin of Arduino. Up to 3 led in parallel is good. A single command in a program can run multiple led in parallel.

https://www.youtube.com/watch?v=JKoMCeg6Qas

Author

Akash Sharma


Visit YouTube

More projects on Arduino nano

  1. 0 to 9 counter using Arduino nano
  2. RADAR system using Arduino nano
Share This Post

1 thought on “Police light using arduino nano”

Leave a Comment