📄 1602-11.c
字号:
#include <Reg51.h>
sbit Rs=P3^3;
sbit Wr=P3^1;
sbit E=P3^0;
sbit Key=P3^2;
unsigned char code DefDot[]={
0x1F,0x1F,0x55,0x55,0xAA,0xAA,0x00,0x1F,0x1F,0x00};
unsigned char code Dis1[]={"ShenZhen ShenHui Technology Co., LTD"};
unsigned char code Dis2[]={" Our Address: Block 513,4th,5th,6th,Floor,Bagualing Industrial Area ShenZhen,China "};
unsigned int DelaySet;
void Int_Ser(void);
void Delay(unsigned int DelayTime);
void WrData(unsigned char DI,unsigned char WData);
void Int_Ser(void) interrupt 0 { //Key Down SUB
unsigned char i;
EX0=0;
for(i=1;i<=0x7F;i++);
if (Key)
{
if(DelaySet>0)
{
DelaySet-=10;
}
else
{
DelaySet=300;
}
for(i=0;i<0x7F;i++);
/* while(!Key);
do
{
while(Key);
for (i=1 ;i<=0x7F;i++);
}
while(Key);*/
}
// while(!Key);
EX0=1;
}
void Delay(unsigned int DelayTime) //DElayTime *2094us
{
unsigned char j;
for (;DelayTime>0;DelayTime--)
{
for(j=0;j<=0x7F;j++)
;
}
}
void WrData(unsigned char DI,unsigned char WData)
{
Rs=DI;
Wr=0;
E=1;
P1=WData;
E=0;
/*Wr=1;
Rs=!DI;
;
E=1;*/
Delay(1);
}
void main(void)
{
unsigned char i,j;
IE=0x81;
IP=0x01;
TCON=0x00;
SP=0x60;
Key=1;
Delay(500);
WrData(0,0x01);
Delay(10);
WrData(0,0x02);
Delay(10);
WrData(0,0x38); //Function SET 2-line DisPlay on
Delay(10);
WrData(0,0x01); //Display Clear
Delay(50);
WrData(0,0x06); //Entry Mode SET Increment Mode
Delay(50);
WrData(0,0x0C); //DisPlay ON Cursor OFF blink OFF
Delay(10);
WrData(0,0x40);
DelaySet=300;
/*for(j=0;j<5;j++)
{
for(i=0;i<4;i++)
{
WrData(1,DefDot[2*j]);
WrData(1,DefDot[2*j+1]);
}
} */
while(1)
{
WrData(0,0x80);
for(j=0;j<16;j++)
{
WrData(1,Dis1[j]);
}
for(i=0;i<98;i++)
{
WrData(0,0xC0);
for(j=0;j<16;j++)
{
WrData(1,Dis2[i+j]);
}
Delay(DelaySet);
}
Delay(3000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -