Keypad Interfacing with Seven Segment Display Through 8051 Microcontroller-7 Segment Display Code in C Programming
Keypad Interfacing with seven segment display through 8051 microcontroller
INTRODUCTION:
- This project corporates the simple interfacing between the popular 4 x 4 keypad matrix with a single seven segment display in order to manually input numbers or ASCII characters on the seven segment display.
- Here the idea is to display any letter on the 7 segment display according to the keypad pressed.
- In this way we can manually display string of characters or numbers.
Which is the idea after all.
KEYPAD MATRIX:
- The keypad matrix is used for interfacing with the seven segment .
- It is 3 x 3 matrix keypad with each key having a specific value as designed by the programmer.
- Alternatively a keypad predefined with symbols can also be interfaced with the seven segment display through 8051 microcontroller board.
SOURCE CODE:
#include<reg51.h>
sbit R0= P1^0;
sbit R1= P1^1;
sbit R2= P1^2;
sbit R3= P1^3;
sbit C0= P1^4;
sbit C1= P1^5;
sbit C2= P1^6;
void seg(unsigned int);
void main()
{
R0=R1=R2=R3=1;
R0=0;
if (C0==0)
seg(0xF9);
R0=R1=R2=R3=1;
R1 =0;
if (C1 ==0)
seg(0xA4);
R0=R1=R2=R3=1;
R2=0;
if(C2 == 0)
seg (0xB0);
R0=R1=R2=R3=1;
R1=0;
if(C0== 0 )
seg (0x99);
R0=R1=R2=R3=0;
R1 = 0;
if (C1==0)
seg(0X92);
R0=R1=R2=R3=0;
R1 = 0;
if (C2==0)
seg(0X82);
R0=R1=R2=R3=0;
R2 = 0;
if (C0==0)
seg(0XF8);
R0=R1=R2=R3=0;
R2 = 0;
if (C1==0)
seg(0X80);
R0=R1=R2=R3=0;
R2 = 0;
if (C2==0)
seg(0X90);
R0=R1=R2=R3=0;
R3 = 0;
if (C1==0)
seg(0XC0);
}
void seg (unsigned int ch)
{
P2=0x00;
P2 = ch;
}
Proteus simulation program:
Explanation:
- Here there are three seven segment displays interfaced with the hex keypad through 8051.
- By using proteus simulation diagram we can pre predict whether the circuit is working or not.
- When different keypads are switched the corresponding number is displayed(0- 9 range).
CONNECTION DIAGRAM:
WORKING:
- Initially the microchip is placed onto the ACP slot after dumping the code in it.
- A 9V power supply is used to power up the circuit on desire.
- Then the 9th pin of the microcontroller is connected to the 5V supply before powerup of the circuit.
- After powering on the circuit the reset pin is connected to ground.
- Whereas the four rows (R0 – R3) are connected to corresponding pins of Port 1 of ATS9852 microcontroller chip as well as the three columns (C0 – C2).
- Secondly the channel port, in this case is the Port 2 of the microcontroller.
- The port 2 is interfaced with the 8 segments(a-g and h for decimal) of single seven segment display component.
- Finally the common pins of the seven segment can be either shorted and given a separate 5v connection or just one common pin can be connected to ground if reset pin is given to 5V pin on the board.
CONNECTION VIDEO:
Click here to see the video.