electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

LCD display with numeric keypad 4x4


Post new topic  Reply to topic    EDAboard.com Forum Index -> Professional Hardware and Electronics Design -> LCD display with numeric keypad 4x4
Author Message
polong_5



Joined: 30 Jul 2008
Posts: 7


Post30 Jul 2008 8:40   

LCD display with numeric keypad 4x4


Hello...
I just to ask regarding to the subject. is there anyone please give me some simple code to display numeric when pressing 4x4 numeric keypad. the lcd displays is 2x20 module and using pic 16f877.
Back to top
Yeeching



Joined: 26 Jul 2008
Posts: 12
Location: Taipei Taiwan


Post03 Aug 2008 4:27   

Re: LCD display with numeric keypad 4x4


Hi,
Please ref. the LCD example c file.
It used for 8051 serial CPU, you may modifiy it for your CPU.

/
/
/ LCD Display
/ Ver. 1.0
/ Date Aug. 2, 2008
/
/ For ref. only
/
/
/*---------------------------------------------------------------------------*/

void LcdDelay(void)
{
int data i;
for(i = 0; i < 2000; i++)
{
}
}

/*---------------------------------------------------------------------------*/

void LcdBusy(void)
{
Lcd_RS = 0;
Lcd_RW = 1;
LcdCmdPort = 0xff;
Lcd_EN = 1;
Lcd_EN = 0;
while((LcdCmdPort & 0x80) != 0)
{
Lcd_EN = 0;
Lcd_EN = 1;
}
Lcd_EN = 1;
}

/*---------------------------------------------------------------------------*/

void LcdCmd(uchar c)
{
LcdBusy();
LcdCmdPort = c;
Lcd_RS = 0;
Lcd_RW = 0;
Lcd_EN = 0;
Lcd_EN = 1;
}

/*---------------------------------------------------------------------------*/

void LcdData(uchar c)
{
LcdBusy();
LcdDataPort = c;
Lcd_RS = 1;
Lcd_RW = 0;
Lcd_EN = 0;
Lcd_EN = 1;
LcdDelay();
}

/*---------------------------------------------------------------------------*/

void LcdInit(void)
{
Lcd_RS = 1;
Lcd_RW = 1;
Lcd_EN = 1;
LcdCmd(0x38);
LcdCmd(0x38);
LcdCmd(0x06);
LcdCmd(0x0c);
LcdCmd(0x02);
}

/*---------------------------------------------------------------------------*/

void LcdXY(uchar x, uchar y)
{
if((y & 0x01) != 0)
LcdCmd(0x80 | (x - 1));
else
LcdCmd(0xc0 | (x - 1));
}

/*---------------------------------------------------------------------------*/

void LcdClr(void)
{
LcdCmd(0x01);
}

/*---------------------------------------------------------------------------*/

void LcdHex(uchar c)
{
LcdData(table[(((c & 0xf0) >> 4) & 0x0f)]);
LcdData(table[(c & 0x0f)]);
}

/*---------------------------------------------------------------------------*/[/tex][/code]

[size=9][color=#999999]Added after 2 minutes:[/color][/size]


/
/ This program used for 8051 serial CPU, Just for your ref.
/
/ Date: Aug. 1, 2008
/
/
/



#include "reg52.h"
#define RS P1_0
#define RW P1_1
#define Enable P1_2
sbit P1_0=0x90;
sbit P1_1=0x91;
sbit P1_2=0x92;
void delay(void);
void InitialLCD(void);
void WriteIns(char);
void WriteData(char);
void WriteString(char,char *);
void CheckBusy(void);
/*void KeyScan(void);*/
char one=0;
char zero=0;
int KeyData=0xff;
int KeyTemp=0xff;

main()
{
char MSG0[]="0123456789";
char MSG1[]="I Love LCD";
char MSG2[]="02 AUG.,2008";
char MSG3[]="R=10K. C=10uF";
char MSG4[]="MCS-51";
char MSG5[]="01234";
char MSG6[]="56789";
char MSG7[]="ABCDE";
char MSG8[]="I Love YOU";

InitialLCD();
WriteString(13,MSG3);

/* while(1)
{
KeyScan();
if(KeyData!=0xff)
{
WriteIns(0x01);
if(KeyData==0)
WriteString(10,MSG1);
else if(KeyData==1)
WriteString(12,MSG2);
else if(KeyData==2)
WriteString(13,MSG3);
else if(KeyData==3)
WriteString(6,MSG4);
KeyData=0xff;
}
}*/
} /* main */

void InitialLCD(void)
{
WriteIns(0x38);
WriteIns(0x38);
WriteIns(0x38);
WriteIns(0x38);
WriteIns(0x08); /* off display */
WriteIns(0x01); /* clear buffer */
WriteIns(0x0e); /* on display */
WriteIns(0x06); /* set input mode */
} /* InitialLCD */

void WriteIns(char instruction)
{
RS=0;
RW=0;
Enable=1;
P2=instruction;
Enable=0;
CheckBusy();
} /* WriteIns */

void WriteData(char i)
{
RS=1;
RW=0;
Enable=1;
P2=i;
Enable=0;
CheckBusy();
} /* WriteData */

void WriteString(count,MSG)
char count;
char MSG[];
{
char i;
for(i=0;i<count;i++)
WriteData(MSG[i]);
} /* WriteString */

void CheckBusy(void)
{
char i=0x80;
while(i&0x80)
{
RS=0;
RW=1;
Enable=1;
i=P2;
Enable=0;
delay();
}
} /* CheckBusy */

void delay(void)
{
int i;
for(i=0;i<10000;i++)
;
} /* delay */

/*void KeyScan(void)
{
char key=0;
char KeyStatus;
char KeyScanLine=0x01;
char col;
char row;
for(col=0;col<2;col++)
{
P3=~KeyScanLine;
KeyStatus=~P3;
KeyStatus>>=2;
for(row=0;row<2;row++)
{
if(KeyStatus==0x01)
{
one=0;
if(KeyTemp!=key)
{
KeyTemp=key;
zero=1;
}
else
{
zero++;
if(zero==5)
KeyData=KeyTemp;
}
}
key++;
KeyStatus>>=1;
} *//* row */
/* KeyScanLine<<=1;
} *//* col */
/*one++;
if(one==5)
{
zero=0;
KeyTemp=0xff;
KeyData=0xff;
}
}*/ /* KeyScan */
Back to top
Google
AdSense
Google Adsense




Post03 Aug 2008 4:27   

Ads




Back to top
polong_5



Joined: 30 Jul 2008
Posts: 7


Post03 Aug 2008 12:03   

Re: LCD display with numeric keypad 4x4


Hi,
thank for the information and c code.

TQ
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Professional Hardware and Electronics Design -> LCD display with numeric keypad 4x4
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
keypad 4x4 &lcd probs!! (5)
Keypad Lock with LCD display with PIC16F84. Help needed (2)
info on IM50240 or PWB50240 LCD numeric display:HELP (4)
4x4 Keypad with PIC18F4520 (6)
4x4 matrix keypad with 16f690 (4)
interface 4x4 keypad with Atmel AT89S52 (1)
Interface to 4x4 Keypad - how to scan the keypad correctly? (3)
Help !! I want to interface 8051 with the 4x4 matrix keypad (5)
Question how to interface 8051 with the 4x4 matrix keypad (6)
4*4 keypad and 20*4 LCD display (3)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS