0% found this document useful (0 votes)
2 views6 pages

Exp 4

The document outlines an experiment to interface a seven-segment display with an Arduino board to display digits 0 to 9. It details the types of seven-segment displays, the necessary apparatus, and the steps for hardware and software setup, including a sample program. Additionally, it includes precautions to take during the experiment and concludes with a result related to temperature and humidity measurement using a different setup.

Uploaded by

Navoreddydas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Exp 4

The document outlines an experiment to interface a seven-segment display with an Arduino board to display digits 0 to 9. It details the types of seven-segment displays, the necessary apparatus, and the steps for hardware and software setup, including a sample program. Additionally, it includes precautions to take during the experiment and concludes with a result related to temperature and humidity measurement using a different setup.

Uploaded by

Navoreddydas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EXPERIMENT-4

Types of seven segment display, Interface a seven-segment display to Arduino board, Installation of LCD
Library. Write a Program to display digits 0 to 9 in seven segment display.
EX-10: Types of seven segment display, interface a seven-segment display to Arduino board write a
program to display digits 0 to 9 in seven segment display.
Aim: To write a Program to display digits 0 to 9 in seven segment display.
Apparatus:

S.No Apparatus Range/Rating Quantity

1 Arduino UNO - 1

2 Bread board - 1

3 Seven segment display - 1

4 Resistors 10k ohms, 330 ohms 3

5 USB Cable - 1

6 Jumper Wires - As per required

Types of seven segment displays:


There are mainly two types of seven-segment displays: common cathode (CC) and common anode (CA).
1) Common Cathode (CC) Seven-Segment Display:

● In this type, all the cathode terminals of the LEDs are connected together and connected to
GND (ground).

● The anode terminals of each LED are individually controlled to turn on/off segments.
● When an anode terminal is connected to VCC (power supply), the corresponding segment
will light up.
2) Common Anode (CA) Seven-Segment Display:

● In this type, all the anode terminals of the LEDs are connected together and connected to
VCC (power supply).

● The cathode terminals of each LED are individually controlled to turn on/off segments.
● When a cathode terminal is connected to GND (ground), the corresponding segment will light
up.

Interface a seven-segment display to Arduino board:

To interface a seven-segment display with an Arduino, it needs to connect the appropriate pins of the display
to the Arduino's digital output pins. Here's a general pinout connection for a common cathode seven-
segment display:

● Connect the common cathode (CC) or common anode (CA) pin of the display to GND or VCC
respectively.
● Connect the individual segment pins of the display to Arduino digital output pins.
● byte SegPins[] = {2,3,4,5,6,7,8}; // 7-segment display pins in the order,{a,b,c,d,e,f,g,dp}
Installation of LCD Library:

For the installation of an LCD library, there are several popular libraries available for Arduino that provide
support for LCD displays. One commonly used library is the "Liquid Crystal" library. Here's how can install
it:

● Open the Arduino IDE on your computer.


● Go to "Sketch" -> "Include Library" -> "Manage Libraries".
● In the Library Manager, search for "Liquid Crystal".
● Locate "Liquid Crystal" by Arduino and click on the "Install" button.
● Wait for the installation to complete.

Once the library is installed, you can use it to control LCD displays.

Hardware procedure:
⮚ Connect the seven segment display and push buttons as per circuit diagram as shown in below..

Connection circuit:
Software procedure:

⮚ Click on Arduino IDE.

⮚ Click on file

⮚ Click on New

⮚ Write a Program as per circuit Pin connections

⮚ Click on compile button, if it shows done compiling then connect Arduino board by using USB cable
and click on tools then select board > select Arduino Uno > select port.

⮚ Click on Upload the code into Arduino Uno by using USB cable.

Program:
const int a = 13;
const int b = 12;
const int c = 11;
const int d = 10;
const int e = 9;
const int f = 8;
const int g = 7;
int k = 0;
const int upPin = 2;
const int DownPin = 3;
int x = 0;
int upx = 0; //up
int upy = 0; //down
int downx = 0; //up
int downy = 0; //down
void setup() {
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode( 2, INPUT);
pinMode( 3, INPUT);
segmentdigit(x);
}
void loop() {
upx = digitalRead(2);
downx = digitalRead(3);
checkupxButtonPress();
checkdownxButtonPress();
if( k ){
k = 0;
turnOff();
segmentdigit(x);
}
}
void checkupxButtonPress()
{
if (upx != upy) {
if (upx == LOW) {
k = 1;
x++;
if(x > 9) x =0 ;
} else {
}
delay(50);
}
upy = upx;
}
void checkdownxButtonPress()
{
if (downx != downy) {
if (downx == LOW) {
k = 1;
x--;
if( x < 0) x =9 ;
} else
delay(50);
}
downy = downx;
}
void segmentdigit(int digit)
{
if(digit!=1 && digit != 4)
digitalWrite(a,HIGH);

if(digit != 5 && digit != 6)


digitalWrite(b,HIGH);

if(digit !=2)
digitalWrite(c,HIGH);
if(digit != 1 && digit !=4 && digit !=7)
digitalWrite(d,HIGH);

if(digit == 2 || digit ==6 || digit == 8 || digit==0)


digitalWrite(e,HIGH);

if(digit != 1 && digit !=2 && digit!=3 && digit !=7)


digitalWrite(f,HIGH);
if (digit!=0 && digit!=1 && digit !=7)
digitalWrite(g,HIGH);
}
void turnOff()
{
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
}

Precautions:
• Take care about given power supply (12V).
• Jumper wires given carefully whenever given circuit connection.

RESULT: Hence The measurement of temperature and humidity was done by using Node MCU and
DHT11 sensor in Arduino IoT

You might also like