资源简介

使用PCF8563、LCD1602,STC89C52、自己写的代码并完美运行。显示年月日周时分秒,并可以分别设置秒分时年月日周、设置定时开关屏、设置五路定时输出、可查询五路输出状态并任意关断、 同时用ds18b20测试温度并显示

资源截图

代码片段和文件信息

#include 
#define uchar unsigned char
#define uint unsigned int
char s1s2min1min2hour1hour2day1day2month1month2year1year2week1week2flag3_lcd1=0flag3_lcd2=0flag3_lcd3=0flag3_lcd4=0flag3_lcd5=0flag3_lcd6=0flagw1=0flagw2=0flagw3=0flagw4=0flagw5=0flagw6=0;
sbit lcdrs=P2^5;
sbit lcden=P2^3;
sbit lcdrw=P2^4;
void delay(uint z)   //延时0.5毫秒
{
uint xy;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)   //1602写状态
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)   //1602写数据
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void bcd_d(uchar sminhourdayweekmonthyear)   //bcd码转十进制
{
uchar cd;
c=s&0x0f;
d=s>>4;
d=d&0x0f;
s1=10*d+c;    //十进制秒
c=min&0x0f;
d=min>>4;
d=d&0x0f;
min1=10*d+c;    //十进制分
c=hour&0x0f;
d=hour>>4;
d=d&0x0f;
hour1=10*d+c;    //十进制时
c=day&0x0f;
d=day>>4;
d=d&0x0f;
day1=10*d+c;    //十进制日
c=week&0x0f;
d=week>>4;
d=d&0x0f;
week1=10*d+c;    //十进制周
c=month&0x0f;
d=month>>4;
d=d&0x0f;
month1=10*d+c;    //十进制月
c=year&0x0f;
d=year>>4;
d=d&0x0f;
year1=10*d+c;    //十进制年
}
void d_write(uchar num)
{
uchar ab;
a=num/10;
b=num%10;
write_data(0x30+a);
write_data(0x30+b);
}
uchar d_bcd(uchar a)    //十进制转bcd码
{
uchar cd;
c=a/10;
d=a%10;
c=c<<4;
c=c|d;
return(c);
}
void LCD1602_init ()
{
lcdrw=0;
write_com(0x38);
write_com(0x0c);    //光标不显示
write_com(0x06);    //写一个光标加1
write_com(0x01);
write_com(0x80);    //第一行开头开始
write_data(‘2‘);    //开头显示字样 20
write_data(‘0‘);
}
void LCD_write(uchar add1uchar add2uchar time)
{
uchar cd;
c=time&0x0f;
d=time>>4;
d=d&0x0f;
write_com(0x80+64*add1+add2);
write_data(0x30+d);
write_data(0x30+c);
}
void display_week()
{
if(week1==0)
{
write_com(0x80+11);
write_data(‘M‘);
write_data(‘O‘);
write_data(‘N‘);
}
if(week1==1)
{
write_com(0x80+11);
write_data(‘T‘);
write_data(‘U‘);
write_data(‘E‘);
write_data(‘ ‘);
}
if(week1==2)
{
write_com(0x80+11);
write_data(‘W‘);
write_data(‘E‘);
write_data(‘D‘);
    write_data(‘ ‘);
}
if(week1==3)
{
write_com(0x80+11);
write_data(‘T‘);
write_data(‘H‘);
write_data(‘U‘);
write_data(‘R‘);
}
if(week1==4)
{
write_com(0x80+11);
write_data(‘F‘);
write_data(‘R‘);
write_data(‘I‘);
write_data(‘ ‘);
}
if(week1==5)
{
write_com(0x80+11);
write_data(‘S‘);
write_data(‘A‘);
write_data(‘T‘);
write_data(‘ ‘);
}
if(week1==6)
{
write_com(0x80+11);
write_data(‘S‘);
write_data(‘U‘);
write_data(‘N‘);
write_data(‘ ‘);
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-01-11 14:12  clock\
     文件        2949  2019-01-11 11:18  clock\1602.c
     文件        1826  2019-01-11 14:07  clock\PCF8563.c
     文件        6376  2009-05-07 14:37  clock\STARTUP.A51
     文件       14057  2019-01-11 13:24  clock\STARTUP.LST
     文件         749  2019-01-11 13:24  clock\STARTUP.OBJ
     文件       60495  2019-01-11 13:24  clock\clock
     文件       57469  2019-01-11 13:24  clock\clock.LST
     文件       75909  2019-01-11 13:24  clock\clock.M51
     文件       71172  2019-01-11 13:24  clock\clock.OBJ
     文件       22014  2019-01-11 14:11  clock\clock.c
     文件       14490  2019-01-11 13:24  clock\clock.hex
     文件          58  2019-01-11 13:24  clock\clock.lnp
     文件         162  2019-01-11 14:12  clock\clock.plg
     文件       58058  2019-01-11 14:12  clock\clock.uvopt
     文件       13400  2019-01-03 17:22  clock\clock.uvproj
     文件       58056  2019-01-11 14:07  clock\clock_uvopt.bak
     文件       13401  2019-01-02 00:52  clock\clock_uvproj.bak
     文件         239  2019-01-01 16:45  clock\delays.c
     文件        1248  2019-01-03 13:25  clock\ds18b20.c
     文件        1777  2019-01-11 13:16  clock\tempture.c

评论

共有 条评论