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

Digit-wise segments display

Breadboard Connection Diagram

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.
Series Navigation<< AR-B10: Car Wiper System using Servo MotorProtected: Day-1: Online Course on Arduino Programing with Practicals >>
Dr. Dattaraj Vidyasagar
Dr. Dattaraj Vidyasagar

M.S. Electronics & Telecomm. (Cleveland Institute of Electronics, Ohio), Associate Member (IETE, Kolkata), Panelist on Dr. Homi Bhabha Foundation, Google certified educator (Level-1), Mentor of Change (MoC-1619) Niti Ayog, Government of India, International Robotics Trainer, Veteran of Applied Electronics since 35+ years.

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