#include<reg51.h>
#include<lcd1602.h>
#define uchar unsigned char
unsigned char code date[]=" I P A 12A ";
unsigned char code
time[]=" V P A 1.5V ";
void write_com(uchar com);
void write_data(uchar date);
void init1602();
void write_sfm(uchar add,uchar date);
void clock_init()
{
uchar i,j;
for (i=0;i<16;i++)
{
write_data(date[i]);
}
write_com(0x80+0x40);
for(j=0;j<16;j++)
{
write_data(time[j]);
}
}
void main()
{
init1602();
clock_init();
}
//以下为自定义的头文件lcd1602.h
#ifndef LCD_CHAR_1602_2005_4_9
#define LCD_CHAR_1602_2005_4_9
#define uchar unsigned char
#define uint unsigned int
sbit lcdrs = P2^0;
sbit lcdrw = P2^1;
sbit lcden = P2^2;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=110;y>0;y--)
{
;
}
}
}
void write_com(uchar com)
{
lcdrw=0;
lcdrs=0;
P3=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcdrw=0;
lcdrs=1;
P3=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init1602()
{
lcdrw=0;
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
-
unsigned char code time[]=" V P A 1.5V ";
//定义的字符串长度小于写的字符数量。
一周热门 更多>