LCD displej s numerickou klávesnicí 4x4

P

polong_5

Guest
Ahoj ...
Jen jsem se zeptat, pokud jde o předmět.Je tu někdo, prosím, dej mi nějaký jednoduchý kód pro zobrazování číselných při stisku 4x4 numerická klávesnice.LCD displeje je 2x20 modul a pomocí pic 16F877.

 
Nazdar,
Prosím, čj.Například LCD c soubor.
Jej použít pro 8051 serial CPU, můžete modifiy to pro váš procesor.

/
/
/ LCD displej
/ Ver.1,0
/ Datum 2.srpna 2008
/
/ Pro čj.jenom
/
/
/*------------------------------------------------ ---------------------------*/

void LcdDelay (void)
(
Údaje int 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));
jiné
LcdCmd (0xC0 | (x - 1));
)

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

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

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

void LcdHex (UCHAR c)
(
LcdData (tabulka [(((c & 0xF0)>> 4) & 0x0f)]);
LcdData (tabulka [(c & 0x0f)]);
)

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

[size = 9] [color = # 999999] Added po 2 minutách: [/ color] [/ size]/
/ Tento program používá pro 8051 serial CPU, Just for your čj.
/
/ Datum: 1.srpna 2008
/
/
/# include "reg52.h"
# define RS P1_0
# define RW P1_1
# define Povolit 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 jeden = 0;
char nula = 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 [] = "Miluji tě";

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) / * vypnutí displeje * /
WriteIns (0x01) / * jasné buffer * /
WriteIns (0x0E) / * na displeji * /
WriteIns (0x06) / * nastavit vstupní režim * /
) / * InitialLCD * /

void WriteIns (char instrukce)
(
RS = 0;
RW = 0;
Enable = 1;
P2 = výuky;
Enable = 0;
CheckBusy ();
) / * WriteIns * /

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

void WriteString (obraz, MSG)
char count;
char msg [];
(
char i;
for (i = 0; i <count; i )
WriteData (MSG );
) / * 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 )
;
) / * Zpoždění * /

/ * void KeyScan (void)
(
char key = 0;
char KeyStatus;
char KeyScanLine = 0x01;
char col;
char řádek;
for (col = 0; col <2; col )
(
P3 = ~ KeyScanLine;
KeyStatus = ~ P3;
KeyStatus>> = 2;
for (row = 0; řádek <2; row )
(
if (KeyStatus == 0x01)
(
jedna = 0;
if (KeyTemp! = key)
(
KeyTemp = key;
zero = 1;
)
jiné
(
nuly ;
if (nula == 5)
KeyData = KeyTemp;
)
)
klíč ;
KeyStatus>> = 1;
) * / / * Radek * /
/ * KeyScanLine <<= 1;
) * / / * Col * /
/ * jeden ;
if (jeden == 5)
(
nula = 0;
KeyTemp = 0xFF;
KeyData = 0xFF;
)
) * / / * KeyScan * /

 

Welcome to EDABoard.com

Sponsor

Back
Top