下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 基于51单片机 DS1302 LCD1602数字时钟显示

基于51单片机 DS1302 LCD1602数字时钟显示.doc

基于51单片机 DS1302 LCD1602数字时钟显示

范二de年代_IQ算什么
2017-10-24 0人阅读 举报 0 0 暂无简介

简介:本文档为《基于51单片机 DS1302 LCD1602数字时钟显示doc》,可适用于工程科技领域

基于单片机DSLCD数字时钟显示#include<regh>#include<intrinsh>#include<stringh>#defineuintunsignedint#defineucharunsignedcharucharcodetable="ILIKEMCU!"sbitRS=P^sbitRW=P^sbitEN=P^sbitIO=P^sbitsclk=P^sbitrst=P^uchar*week={"SUN","****","MON","TUS","WEN","THU","FRI","SAT"}ucharlcdbuffer={"DATE"}ucharlcdbuffer={"TIME::"}uchardatetimevoiddelay(ucharms){uchariwhile(ms)for(i=i<i)}忙检测ucharbusy(){uchartestRW=RS=EN=test=PEN=returntest}写LCD命令voidwritecmd(ucharcmd){while((busy()x)==x)RS=RW=P=cmdEN=delay()EN=}发送数据voidwritedata(uchardat){while((busy()x)==x)RW=RS=P=datEN=delay()EN=}voidinit(){writecmd(x)delay()writecmd(x)delay()writecmd(x)delay()writecmd(xc)delay()}voidwriteabytetods(ucharx){ucharifor(i=i<i){IO=xxsclk=sclk=x=x>>}}uchargetabytefromds(){uchari,b=xfor(i=i<i){b|=crol((uchar)IO,i)sclk=sclk=}returnb*b}ucharreaddata(ucharaddr){uchardatrst=sclk=rst=writeabytetods(addr)dat=getabytefromds()sclk=sclk=returndat}voidgettime(){uchari,addr=xfor(i=i<i){datetimei=readdata(addr)addr=addr}}voidsetpos(ucharp){writecmd(p|x)}voiddispalystring(ucharp,uchar*s){ucharisetpos(p)for(i=i<i){writedata(si)delay()}}voidzhuanhuan(uchard,uchar*a){a=d''a=d''}voidmain(){init()while(){gettime()zhuanhuan(datetime,lcdbuffer)zhuanhuan(datetime,lcdbuffer)zhuanhuan(datetime,lcdbuffer)strcpy(lcdbuffer,weekdatetime)zhuanhuan(datetime,lcdbuffer)zhuanhuan(datetime,lcdbuffer)zhuanhuan(datetime,lcdbuffer)dispalystring(x,lcdbuffer)dispalystring(x,lcdbuffer)}}

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/7

基于51单片机 DS1302 LCD1602数字时钟显示

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利