- AR-B1: Blinking LED Project using Arduino
- AR-B2: Alternate Control of LED & Buzzer
- AR-B3: Alternate Blinking LEDs
- AR-B4: Running Effect of LEDs
- AR-B5: Chasing Effect of LEDs
- AR-B6: Obstacle Detector using IR Sensor
- AR-B7: Object Counter using Serial Monitor
- AR-B8: Servo Motor Basic Code
- AR-B10: Car Wiper System using Servo Motor
- B13: LED Display Down Counter with Alarm using Arduino
- Protected: Day-1: Online Course on Arduino Programing with Practicals
- Protected: Day-2: Online Course on Arduino Programing with Practicals
- Protected: Day-3: Online Course on Arduino Programing with Practicals
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.
Parts List
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
- The 100 ohm resistor must be connected at any one center pin of LED display and ground pin of Arduino.
- Connect jumper wires coming from LED display pins to respective pins of Arduino as shown in above circuits.
- Connect the +ve and -ve terminals of buzzer correctly.