Download counter using LED display and Arduino

B13: LED Display Down Counter with Alarm using Arduino

This entry is part 10 of 13 in the series Arduino Basic Circuits

In this code the LED display shows counting from 9 – 0. When 0 appears on the display it produces buzzer sound. The pin configuration of LED display and connection diagram is given below.

Common cathode LED display – 1, buzzer – 1, jumper wires (male-male) – 10, Arduino UNO – 1, data cable – 1, resistor 100 ohm (1W) – 1
Note: 100 ohm (1W) resistor is must. If you use small resistor, then it will burn out.

The Code

This code has many applications like in down counter for a typical application or say in controlling a particular gadget through timer.

Just copy the following code and upload it in Arduino UNO to check its working.

int a = 2; 
int b = 3;
int c = 4;
int d = 5;
int e = 6;
int f = 7;
int g = 8;
int buzzer = 11;
void setup()
{
  pinMode(a,OUTPUT);
  pinMode(b,OUTPUT);
  pinMode(c,OUTPUT);
  pinMode(d,OUTPUT);
  pinMode(e,OUTPUT);
  pinMode(f,OUTPUT);
  pinMode(g,OUTPUT);
  pinMode(buzzer,OUTPUT);
}

void loop()
{
  digitalWrite(a,HIGH); // display 9
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);
  digitalWrite(e,LOW);
  digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,HIGH); // display 8
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);
  digitalWrite(e,HIGH);
  digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,HIGH); // display 7
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,LOW);
  digitalWrite(e,LOW);
  digitalWrite(f,HIGH);
  digitalWrite(g,LOW);
  delay(1000);

  digitalWrite(a,HIGH); // display 6
  digitalWrite(b,LOW);
  digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);
  digitalWrite(e,HIGH);
  digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,HIGH); // display 5
  digitalWrite(b,LOW);
  digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);
  digitalWrite(e,LOW);
  digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,LOW); // display 4
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,LOW);
  digitalWrite(e,LOW);
  digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,HIGH); // display 3
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);
  digitalWrite(e,LOW);
  digitalWrite(f,LOW);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,HIGH); // display 2
  digitalWrite(b,HIGH);
  digitalWrite(c,LOW);
  digitalWrite(d,HIGH);
  digitalWrite(e,HIGH);
  digitalWrite(f,LOW);
  digitalWrite(g,HIGH);
  delay(1000);
  
  digitalWrite(a,LOW); // display 1
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,LOW);
  digitalWrite(e,LOW);
  digitalWrite(f,LOW);
  digitalWrite(g,LOW);
  delay(1000);
  
  digitalWrite(a,HIGH); // display 0
  digitalWrite(b,HIGH);
  digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);
  digitalWrite(e,HIGH);
  digitalWrite(f,HIGH);
  digitalWrite(g,LOW);
  digitalWrite(buzzer,HIGH);
  delay(1000);
  digitalWrite(buzzer,LOW);
}


Common Cathode LED Display Pinout

image 2 Vidyasagar Academy

Digit-wise segments display

image 3 Vidyasagar Academy
image 4 Vidyasagar Academy
image 5 Vidyasagar Academy

Breadboard Connection Diagram

LED Display with Arduino Vidyasagar Academy

Precautions

  1. The 100 ohm resistor must be connected at any one center pin of LED display and ground pin of Arduino.
  2. Connect jumper wires coming from LED display pins to respective pins of Arduino as shown in above circuits.
  3. Connect the +ve and -ve terminals of buzzer correctly.
Share on your network!
Prof. Dattaraj Vidyasagar
Prof. Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x