#include <reg52.h>
#include <intrins.h>
#include <absacc.h>
sbit IN0=P3^2;
#define uchar unsigned char
#define uint unsigned int
sbit TuiBi=P3^1;
uchar m=0;
uchar a;
sbit Row1=P1^0;
sbit Row2=P1^1;
sbit Row3=P1^2;
sbit Line1=P1^3;
sbit Line2=P1^4;
sbit Line3=P1^5;
uchar code chuhuo[]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};sbit LCD_EP=P3^6;
sbit LCD_RW=P3^5;
sbit LCD_RS=P3^4;
#define LCD_Out P0
#define LCD_In P0
code uchar LCD_addr[18]={
0x85,0xc5,0x86,0xc1,
0x81,0xc3,0x83,0xc3,
0x83,0xc0,0x81,0xc0,
0x81,0xc6,0x84,0xc6,0x81,0xc3
};
code uchar LCD_InitialCode[]={0x30,0x30,0x30,0x38,0x01,0x06,0x0c};
uchar*string_s1,*string_s2;
uchar i,j;
void delay(uint count)
{
uint i;
while(--count!=0)
for(i=0;i<125;i++);
}
void main()
{
LCD();
a=Data;
EA=1;
EX0=1;
IT0=1;
while(1)
{
Row1=0;Row2=0;Row3=0;Line1=1;Line2=1;Line3=1;TuiBi=1;
P2=chuhuo[m];
delay (500) ;
}
}
void into_ISR(void) interrupt 0
{
if (IN0==0)
{
delay(10);
if(IN0==0)
{
Row1=0;Row2=1;Row3=1;
if(Line1==0)
{
if(a>=1)
{
m=1;a=a-1;Data=a;
LCD();
}
else Tishi();
return;
}
else if (Line2==0)
{
m=5;a=a-2;Data=a;
LCD();
}
else Tishi();
return;
}
else if (Line3==0)
{
if(a>=2)
{
m=6;a=a-2;Data=a;
LCD();
}
else Tishi();
return;
}
Row1=1;Row2=1;Row3=0;
if (Line1==0)
{
if (a>=3)
{
m=8;a=a-3;Data=a;
LCD();
}
else Tishi();
return;
}
else if(Line3==0)
{
TuiBi=0;
String_s1="We appreciate yours";
String_s2="Business,bye!";
LCD();
return
}
}
}
}
void LCD_DataWrite(unsigned char Data)
{
unsigned int Read_Dat=0;
LCD_EP=0;
LCD_RS=0;
LCD_RW=1;
do{
LCD_In=0xff;
LCD_EP=1;
Read_Dat=LCD_In&0x80;
LCD_EP=0;
}
whlie(Read_Dat!=0);
LCD_RW=0;
LCD_RS=1;
LCD_Out=Data;
LCD_EP=1;
LCD_EP=0;
}
void LCD_RegWrite(uchar Command)
{
uint Read_Dat=0;
LCD_EP=0;
LCD_RS=0;
LCD_RW=1;
do {
LCD_In=0xff;
LCD_EP=1;
Rrad_Dat=LCD_In&0x80;
LCD_EP=0;
}
whlie(Read_Dat!=0);
LCD_RW=0;
LCD_Out=Command;
LCD_EP=1;
LCD_EP=0;
}
unsigned char LCD_StatusRead(void)
{
unsigned char Read_Dat=0;
LCD_EP=0;
LCD_RS=0;
LCD_RW=1;
LCD_In=0xff;
LCD_EP=1;
Read_Dat=LCD_In;
LCD_EP=0;
return Read_Dat;
}
void LCD_Init(void)
{
uchar uiTemp=0,i;
uchar *Point;
Point=(uchar*)LCD_InitialCode;
LCD_EP= 0;
LCD_RS= 0;
LCD_RW= 0;
for(i=0;i<4;i++)
{
uiTemp=*Point++;
LCD_Out = uiTemp;
LCD_EP=1;
LCD_EP=0;
delay(5)
}
LCD_RegWrite(*Point++);
LCD_RegWrite(*Point++);
LCD_RegWrite(*Point++);
}
void LCD()
{
uchar uiTemp=O;
LCD_Init();
uiTemp= LCD_StatusRead();
LCD_RegWrite(LCD_addr[i]);
while((*String_s1)!=0)
{
LCD_DataWrite(*String_s1);
}
LCD_RegWrite(LCD_addr[j]);
while((*String_s2)!=0)
{
LCD_DaraWrite(*String_s2);
String_s2++;
}
void Tishi()
{
sbit d=P3^3;
sbit c=P3^7;
sbit f;
void baojing()
{
EA=1;
EX0=1;
IT0=1;
c=1;
}
if(
}
void extero() interrupt 0
{
f=1;
}
}
|