📄 ic2.c
字号:
// LCD 16X2 5x7
#include <INTRINS.H>
#include <AT89x51.H>
#include <delay.h>
#define uchar unsigned char
#define uint unsigned int
//*************************************************
uchar idata system[]={0x20,0x49,0x43,0x20,0x43,0x41,0x52,0x44,
0x20,0x53,0x59,0x53,0x54,0x45,0x4d,0x00};
uchar idata beyond[]={0x20,0x42,0x45,0x59,0x4f,0x4e,0x44,0x20,
0x20,0x20,0x55,0x45,0x53,0x54,0x43,0x00};
uchar idata id[]={0x20,0x20,0x20,0x20,0x07,0x07,0x07,0x07,
0x07,0x07,0x07,0x07,0x20,0x20,0x20,0x00};
uchar idata money[]={0x20,0x20,0x07,0x07,0x20,0x20,0x20,0x5c,
0x3a,0x07,0x07,0x2e,0x07,0x07,0x20,0x00};
uchar idata byte[]={0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42};
uchar idata pass[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
//*************************************************
sbit RST=P1^3; sbit SCL=P1^2; sbit SDA=P1^4; sbit IC=P1^1;
sbit en=P1^7; sbit rs=P1^5; sbit rw=P1^6;
sbit a0=ACC^0; sbit a1=ACC^1; sbit a2=ACC^2; sbit a3=ACC^3;
sbit a4=ACC^4; sbit a5=ACC^5; sbit a6=ACC^6; sbit a7=ACC^7;
//*************************************************
//*************************************************
void wait(void){ en=0; rs=0; rw=1;
do {en=0;en=1;_nop_();ACC=P0;en=0;} while(a7==1); }
//*************************************************
void command(uchar a){
en=0;rs=0;rw=0;en=1;P0=a;_nop_();en=0;wait();}
//*************************************************
void reset(void){
en=0;rs=0;rw=0;en=1;P0=0x38;_nop_();en=0;delay(0x09);
en=0;rs=0;rw=0;en=1;P0=0x38;_nop_();en=0;delay(0x06);command(0x38);}
//*************************************************
void lcdstart(void){
reset();
command(0x38);
command(0x06);
command(0x0c);
command(0x01);}
//*************************************************
void display(s) uchar idata *s;
{uchar i=0;while (s[i]!=0x00){en=0;rs=1;rw=0;
en=1;P0=s[i];en=0;wait();i++;_nop_();} }
//*************************************************
//*************************************************
main(){
lcdstart(); while(1){
command(0x80);display(system);
command(0xc0);display(beyond);
delay(0xff);
command(0x80);display(id);
command(0xc0);display(money);
delay(0xff);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -