详情请进入 湖南阳光电子学校 已关注:人 咨询电话:0731-85579057 微信号:yp941688, yp94168
sbitLCD_RS=P3^4;//定义IO口,具体1602的读控制线sbitLCD_RW=P3^3;//定义IO口,具体1602的写控制线sbitLCD_EN=P2^0;//定义IO口,具体1602的使能控制线sbitLight=P3^7;//定义IO口,具体1602的背光控制线(0:开通,1关闭)sbitD0=P1^0;//定义IO口,P1.0数据口1602LCD的D0口sbitD1=P1^1;//定义IO口,P1.1数据口1602LCD的D1口sbitD2=P1^2;//定义IO口,P1.2数据口1602LCD的D2口sbitD3=P1^3;//定义IO口,P1.3数据口1602LCD的D3口sbitD4=P1^4;//定义IO口,P1.4数据口1602LCD的D4口sbitD5=P1^5;//定义IO口,P1.5数据口1602LCD的D5口sbitD6=P1^6;//定义IO口,P1.6数据口1602LCD的D6口sbitD7=P2^1;//定义IO口,P2.1数据口1602LCD的D7口sbitB_0=B^0;//定义变量B的位,方便位操作sbitB_1=B^1;sbitB_2=B^2;sbitB_3=B^3;sbitB_4=B^4;sbitB_5=B^5;sbitB_6=B^6;sbitB_7=B^7;voidmain(void){P1M0=0x00;P1M1=0x00;//配置P1口为准双向口P2M0=0x00;P2M1=0x00;//配置P2口为准双向口P3M0=0x00;P3M1=0x80;//配置P3.7口为强推挽输出(控制背光),其它IO口默认为准双向口(详细配置见STC12C56XXAD数据手册)Light=0;//开1602LCD的背光lcd_init();//LCD初始化lcd_write_char(0,0,'A');//在坐标(0,0)处写入Alcd_write_char(1,0,'B');//在坐标(1,0)处写入Blcd_write_char(2,0,'C');//在坐标(2,0)处写入Clcd_write_char(3,0,'D');//在坐标(3,0)处写入Dlcd_write_char(4,0,'E');//在坐标(4,0)处写入Elcd_write_char(5,0,'F');//在坐标(5,0)处写入Flcd_write_char(6,0,'G');//在坐标(6,0)处写入Glcd_write_char(7,0,'H');//在坐标(7,0)处写入Hlcd_write_char(8,0,'I');//在坐标(8,0)处写入Ilcd_write_char(9,0,'J');//在坐标(9,0)处写入Jlcd_write_char(10,0,'K');//在坐标(10,0)处写入Klcd_write_char(11,0,'L');//在坐标(11,0)处写入Llcd_write_char(12,0,'M');//在坐标(12,0)处写入Mlcd_write_char(13,0,'N');//在坐标(13,0)处写入Nlcd_write_char(14,0,'O');//在坐标(14,0)处写入Olcd_write_char(15,0,'P');//在坐标(15,0)处写入Plcd_write_char(0,1,'Q');//在坐标(0,1)处写入Qlcd_write_char(1,1,'R');//在坐标(1,1)处写入Rlcd_write_char(2,1,'S');//在坐标(2,1)处写入Slcd_write_char(3,1,'T');//在坐标(3,1)处写入Tlcd_write_char(4,1,'U');//在坐标(4,1)处写入Ulcd_write_char(5,1,'V');//在坐标(5,1)处写入Vlcd_write_char(6,1,'W');//在坐标(6,1)处写入Wlcd_write_char(7,1,'X');//在坐标(7,1)处写入Xlcd_write_char(8,1,'Y');//在坐标(8,1)处写入Ylcd_write_char(9,1,'Z');//在坐标(9,1)处写入Zwhile(1)//进入程序主循环{}}voiddelay1(intms)//延时子函数,用于模拟时序中高低电平的保持时间,非精确的定时{unsignedchary;while(ms--){for(y=0;y.(编辑:德惠电工培训学校)