#include<reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit LCD_RS = P2^6;
sbit LCD_RW = P2^5;
sbit LCD_EN = P2^7;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
LCD_RS=1;
LCD_RW=0;
LCD_EN=0;
P0=com;
_nop_();
_nop_();
_nop_();
_nop_();
LCD_EN=1;
_nop_();
_nop_();
_nop_();
_nop_();
LCD_EN=0;
}
void write_data(uchar date)
{
LCD_RS=1;
P0=date;
delay(5);
LCD_EN=1;
delay(5);
LCD_EN=0;
}
void init()
{
//delay(15); //等待LCD电源稳定
write_com(0x38); //16*2显示,5*7点阵,8位数据
delay(5);
write_com(0x0f);
delay(5);
write_com(0x06);
delay(5);
write_com(0x01);
delay(5);
write_com(0x80);
delay(5);
}
void main()
{
init();
write_data('1');
while(1);
}
此帖出自
小平头技术问答
一周热门 更多>