Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

seven segment display display 0 to 9 program with arduino

The document outlines a project to interface a 7-segment display with an Arduino to display numbers from 0 to 9 sequentially. It includes a list of required components, a description of the display's operation, and a detailed Arduino program for controlling the display. The procedure emphasizes proper connections and precautions to ensure successful operation.

Uploaded by

arushiingle5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

seven segment display display 0 to 9 program with arduino

The document outlines a project to interface a 7-segment display with an Arduino to display numbers from 0 to 9 sequentially. It includes a list of required components, a description of the display's operation, and a detailed Arduino program for controlling the display. The procedure emphasizes proper connections and precautions to ensure successful operation.

Uploaded by

arushiingle5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

seven segment display display 0 to 9 program with arduino

Objective:

To interface a 7-segment display with an Arduino and program it to show numbers from 0 to 9
sequentially.

Apparatus & Components:

 Arduino Uno

 7-segment display (Common Cathode)

 7 x 220Ω resistors

 Connecting wires

 Breadboard

Seven Segment Display Types

There are basically 2 types of seven-segment LED displays:


Hex
Number gfedcba
Code

0 0111111 3F

1 0000110 06

2 1011011 5B

3 1001111 4F

4 1100110 66

5 1101101 6D

6 1111101 7D

7 0000111 07

8 1111111 7F

9 1001111 4F

Table: Display numbers on a seven-segment display in common cathode configuration.


Theory:

A 7-segment display consists of seven LEDs arranged in the shape of an "8". Each LED is controlled
separately to form different numbers. The Arduino sends HIGH or LOW signals to each segment to
display a number.

Program

int a = 2;
int b = 3;
int c = 4;
int d = 5;
int e = 6;
int f = 7;
int g = 8;

void setup() {
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
}

void loop() {
void loop()
{
int a = 2;
int b = 3;
int c = 4;
int d = 5;
int e = 6;
int f = 7;
int g = 8;

void setup() {
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
}

void loop()
{
// Display '0'
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
delay(3000);

// Display '1'
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(3000);

// Display '2'
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
delay(3000);

// Display '3'
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
delay(3000);

// Display '4'
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(3000);

// Display '5'
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(3000);

// Display '6'
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(3000);

// Display '7'
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(3000);

// Display '8'
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(3000);

// Display '9'
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(3000);
}

Procedure:

1. Connect the seven-segment display to the Arduino as per the circuit diagram.

2. Connect resistors (220Ω) in series with each segment to limit current.

3. Write and upload the Arduino program to cycle through numbers 0-9.

4. Observe the numbers changing on the display every second.

5. conclusion:

The experiment demonstrates how to interface a 7-segment display with an Arduino and
control it using digital signals. The display works correctly and cycles through numbers
without errors.

Precautions & Errors:

✅ Ensure correct pin connections between Arduino and display.


✅ Use 220Ω resistors to prevent segment burnout.
✅ If the display doesn’t work, check if it's common anode or cathode and adjust the code
accordingly.

You might also like