Blink Leds using Arduino

How to blink three Leds sequentially using Arduino, A traffic light system

Category: Arduino Tags: C Programming

Blink Led using Arduino


    Everyday we see traffic lights on roads, Red, Green and Orange lights turn on and off within a fixed time duration and only one light is on at a time. We can make similar system with Arduino. Look at the diagram below.

Arduino Led Blink (Traffic light system)
Fig 1: Arduino Led Blink (Traffic light system)


    As shown in figure we can control red, green and blue Led's with any Arduino pins, in above diagram we used pin 13, 12 and 11 for RGB respectively. Lets look at the code we will upload to the board:

int red = 13;
int green = 12;
int blue = 11;

void setup() {
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);

void loop() {
  //red ON
  digitalWrite(red, HIGH);
  digitalWrite(green, LOW);
  digitalWrite(blue, LOW);

  //green ON
  digitalWrite(green, HIGH);
  digitalWrite(red, LOW);
  digitalWrite(blue, LOW);

  //blue ON
  digitalWrite(blue, HIGH);
  digitalWrite(red, LOW);
  digitalWrite(green, LOW);

In above code pinMode is used to set pins as output pins and digitalWrite method is used to make output High and Low. Whenever output goes high for a pin, respective led turns on and turns off if it is low. Below is the video of the tutorial.


Like 0 People
Last modified on 19 July 2020
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 158
Questions: 16
Given Best Solutions: 16 *


No Comments Yet

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User