LCD1602驱动C51程序带三种显示方式

  • 格式:txt
  • 大小:2.27 KB
  • 文档页数:1
outshuzu[i-1]=0;
}
}
if(out3>0)
{
n=0;
LCD_write_data(0x2e);
while(n<2)
{
out4=out3*10;
out3=out3*10;
outshuzu[n]=out4%10;
LCD_write_data(0x30+outshuzu[n]);
}
else
{
while(out1!=0)
{
outshuzu[n++]=out1%10;
out1=out1/10;
}
LCD_write_com(0x80+0x40);
for(i=n;i>0;i--)
{
LCD_write_data(0x30+outshuzu[i-1]);
LCD_write_com(0x06);//写完数据后右移
LCD_write_com(0x01);//清屏
LCD_write_com(0x80);//设置初始地址
}
void show(long da,address)
{
uchar dat[16];
uchar i=1;
LCD_write_com(0x80&档定为低质量也实属情有可原,故这段废话只为避免低质量的评定,见谅
/************液晶1602初始化及基础程序**************/
#define uchar unsigned char
#define uint unsigned int
for(x=z;x>0;x--)
for(y=82;y>0;y--);
}
void delay_10us(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=5;y>0;y--);
}
void delay_1us()
{
_nop_();
_nop_();
{
uchar i,n=0,outshuzu[4];
uint out1,out4;
double out3;
out1=out;
out3=out-out1;
if(out1==0)
{
LCD_write_com(0x80+0x40);
LCD_write_data(0x30);
{
rs=1;
rw=0;
P0=dat;
delay_100us(5);
en=1;
delay_100us(5);
en=0;
}
void LCD_init()
{
en=0;
rw=0;
LCD_write_com(0x38);//显示模式
LCD_write_com(0x0f);//光标控制(显示并闪烁)
_nop_();
_nop_();
}
void LCD_write_com(uchar com)
{
rs=0;
rw=0;
P0=com;
delay_100us(5);
en=1;
delay_100us(5);
en=0;
}
void LCD_write_data(uchar dat)
while(*p !='\0')
{
LCD_write_data(*p);
p++;
}
}
/****************************************************************************/
void show2(double out)
outshuzu[n]=0;
n++;
}
n=0;
}
}
* 名称:DisText()
* 功能:显示文本函数
****************************************************************************/
void write_text(uint *p,uint addr)
{
LCD_write_com(0x80+addr);
for(i=1;da!=0;i++)
{
dat[i]=da%10;
da=da/10;
}
for(i=i-1;i>0;i--)
{
LCD_write_data(0x30+dat[i]);
}
}
/****************************************************************************
sbit rs=P2^2;
sbit rw=P2^1;
sbit en=P2^0;
Байду номын сангаас
void delay_1ms(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=850;y>0;y--);
}
void delay_100us(uint z)
{
uint x,y;

下载文档原格式

  / 1

相关主题