4x4 Keypad Interfacing Using AT89V51 Microcontroller
In this Tutorial we Interface 4x4 keypad using AT89V51 Microcontroller and display the result on LCD screen.
Connections:
#include<reg51.h>
#include<lcd2.h>
sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit LED3 = P1^2;
sbit LED4 = P1^3;
sbit r1 = P3^0;
sbit r2 = P3^1;
sbit r3 = P3^2;
sbit r4 = P3^3;
sbit c1 = P3^4;
sbit c2 = P3^5;
sbit c3 = P3^6;
sbit c4 = P3^7;
void main ()
{
while (1)
{
lcd_init();
r2=r3=r4=1;
c1=c2=c3=c4=1;
r1=0;
if(c1==0)
{
lcd_cmd(0x01);
display("Hello");
delay(1);
}
if(c2==0)
{
lcd_cmd(0x01);
display("Hi");
delay(1);
}
r1=r3=r4=1;
c1=c2=c3=c4=1;
r2=0;
if(c1==0)
{
lcd_cmd(0x01);
display("Yes");
}
if(c2==0)
{
LED2 = 1;
}
r1=r2=r4=1;
c1=c2=c3=c4=1;
r3=0;
if(c1==0)
{
lcd_cmd(0x01);
display("No");
}
if(c2==0)
{
LED3 = 1;
}
r1=r2=r3=1;
c1=c2=c3=c4=1;
r4=0;
if(c1==0)
{
//LED4 = 0;
//while(c2==0);
lcd_cmd(0x01);
display("No");
}
if(c2==0)
{
LED4 = 1;
}
}
}
Output:
Comments
Post a Comment