专业版
#第八届立创电赛#智能时钟

创建时间:1年前

描述

<div class="document"> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 1、项目功能介绍</h3> <p> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">1.时钟显示-----通过按键设置保存后可显示时钟</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">2.温湿度显示-----电路中设计了DHT11传感器,可实时显示所测环境温度,湿度,每5秒刷新一次数据</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">3.闹钟设定-----可设定一个任意时间的闹钟,闹钟状态支持开启和关闭</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">4.联网校时------为了解决走时不准确,以及不想手动调时的问题,在原基础上增加了联网校时(使用esp01s模块),每两分钟更新一次,时间的误差调整在1S之内</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">5.掉电保存数据-----在掉电之前,每分钟保存一次数据到flash;闹钟在每次设定完成之后都会保存到flash,避免突然断电导致每次上电都需要重新设置闹钟</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">6.内置电池,可独立工作-----内置500mah电池,可供时钟在外部电源断开后工作一段时间</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">7.充放电保护电路-----设计了TP4056进行小电流给电池充电,及DW01A和FS8205组成的电池保护电路,保证电池在充放电及工作的过程中不会出现问题</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">8.电源切换-----由于此时钟一般是由外部电源供电,为了避免外部电源供电和电池供电冲突,因此设计了电源切换电路,保证两者同时存在时,由外部电源供电,没有外部电源时,由电池进行供电</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*2、项目属性</h3> <hr class="horizontal-splitline normal-bold-2"> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">  本项目来源于EDA暑期训练营2023,电路和软件设计参考官方方案,同时融入了自己的想法和设计,项目首次公开</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 3、开源协议</h3> <hr class="horizontal-splitline normal-bold-2"> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">  项目使用GPL3.0协议</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p> </p> <p style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*4、硬件部分</h3> <p>  <strong> </strong> 时钟主控芯片电路,控制时间显示,以及其他功能的进行。</p> <hr class="horizontal-splitline normal-bold-2"> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/xHMAD31TrRWI5ZMforMoeBY9EfQCVpL6qN6Oh599.png" alt="" width="360" height="367"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">      电源切换电路,电路虽然简单,却能起到重要的作用;当VBUS(外部电源)没有供电时,Q2的栅极被下拉电阻拉低,Q2Mos管导通,切换为电池供电;当VBUS(外部电源)供电时,Q2的栅极电平被VBUS拉高,Q2Mos管关闭,切换为VBUS(外部电源)供电。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/hXvalueITXLjm9C6prpPUFcMe43KxeCha8XG3atL.png" alt="" width="365" height="189"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">    DHT11温湿度传感器电路图,5V供电,这个上拉电阻用于协助数据传输。因为DHT11的数据口是漏极开路,如果不接上拉电阻,则只能输出低电平和高阻态,不能输出高电平,因此需要外接上拉电阻,否则无法输出1。DHT11的工作电流约为1mA,VCC一般为5V,则电阻R=5V/1mA=5KΩ。一般3.3k~10k都可以。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/VkX0wMoSxf84vvtiQhiQONRnnJyx6edfWGFT2N9x.png" alt="" width="361" height="301"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">      ESP01S电路图,ESP01S和瑞萨单片机的通信方式使用串口通信的方式。这里本来设计的是和串口2通信的,但由于软件上没有调试出来,因此改为和串口9进行通信(串口9)是正常工作的,<span style="color:#e03e2d;">但是需要注意的是串口9是用来串口烧程序的,如果先焊接了esp01s,就会影响程序烧录,因此需要先用串口烧录好瑞萨芯片的程序,以及esp01s的程序,再焊接esp01s。</span></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/AwqjU2FzwMnUAVBUW31zrYbvAm5Ap7pab6B5l9JA.png" alt="" width="356" height="209"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">      蜂鸣器电路电路图,用IO口控制mos管的开管,来控制蜂鸣器发声;这里使用无源蜂鸣器,因此使用IO输出PWM控制蜂鸣器发出声音。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/kFpsPh2yrxDtWZs2yJh6N7R1dCr8RDoiVPPB0nYI.png" alt="" width="358" height="282"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">      3.3V降压电路,用于给esp01s供电,这款LDO具有低压降的特点,输入最低3.6V就可以输出3.3V的电压,刚好适合3.7V锂电池供电的降压电路。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/fSBmp5MuGPiylOgy4hwVwIBabvh9fYPjpRG7mswV.png" alt="" width="359" height="230"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">     功能按键电路,用于修改时钟的设定,以及查看设定等。通过将按键的一端接地,一端接瑞萨芯片的IO口,连接按键的IO口通过软件设置电平上拉;当按键按下时,对应的IO口电平被拉低,芯片可以读到对应IO口的电平并作出相应的工作。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/zNKv8wzQRx6oqdG6xT9EVfiqoHlErBxVGUpyAgR8.png" alt="" width="339" height="419"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">      复位,BOOT按键电路,用于串口程序烧录。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/iWHyijs6lvLIjm2qZjrvOiwllR6BafxNXcRdOGuh.png" alt="" width="330" height="263"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">       数码管电路图,直接连接主控芯片IO口,需要注意连接IO的各个数码管引脚字母顺序,以及网络名称,不然写出的程序可能达不到想要的效果。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/dk3bsBR2T4EcQcHFTEYxGgCjtMmscDDvM2jFufeI.png" alt="" width="394" height="419"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">       电池充电电路图,TP4056作为经典的充电芯片,还是挺好用的,而且价格便宜。可以通过电阻设置充电电流,充电和满电都有指示灯提示。PROG设置充电电流大小,这里设置的10K,根据手册里公式计算,这里的充电电流大概是120ma。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/RSjPobA3d9MhrSczTp0JK5bERGxBLCyejKrtF1pb.png" alt="" width="439" height="281"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">     充放电保护电路,DW01A和FS8205搭配,组成电池保护电路,当电压超过4.2V或者低于2.52V时,关闭FS8205mos管,避免电池过冲或者过放。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/cqmEqM3I6KuWdBHm0JMLVtE0hGUgGqhsqXyjHl10.png" alt="" width="433" height="334"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">       串口下载接口,用于下载程序。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/ARu2wTvtc7LJiR6cpxaQRJgDALiAuEYUeCjpcXAi.png" alt="" width="434" height="364"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*5、软件部分</h3> <p>      写的头文件,及源程序主要程序在src中</p> <hr class="horizontal-splitline normal-bold-2"> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/KI3ocXwBGMyTILNru2PDOCG9FFOcLHGRkVZCpuvZ.png" alt="" width="379" height="601"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">    主程序,对各个功能或引脚进行初始化,以及主函数的编写</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> <img src="//image.lceda.cn/pullimage/3CNnI4rJrONtcVOLs99TIVll8vPV61cImYmPV3mz.png" alt="" width="847" height="638"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">     串口回调函数,用于串口发送和接收数据</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/CUN2ql8BbaGzkuTkrggafJ1JTzDbtH8BNe2PTzAI.png" alt="" width="788" height="475"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">      串口对接收到的数据进行处理,由于接收到的数据是ASCLL码,因此不能直接使用,需要进行转化。由于对时间的数据只需要0到9即可,因此只对ASCLL数据中为48到57的数字进行处理,得到需要的数字,其他的字符当做无用字符,等于0,避免干扰串口调节时间。再将数组中数据一一转化为需要的时间数据,便于后面校时。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/xQSieUCMpFwMpXS6y0y3IcbqnsjDFny1ROfNF1jP.png" alt="" width="877" height="561"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">串口校正时间,当串口接收数据完成后,判断是否是正确的时间,如果是,则进行校正。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/Nxnds6M2ts5VZ5kh6hk6PplAidYYj6Et77qWdbv5.png" alt="" width="921" height="437"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">   将数据写入flash,避免数据丢失</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/Xt7FJikWF5Q7gyISwFcYcBW4KJxozvTzygBOfCR4.png" alt="" width="897" height="347"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">        在时间设定好后,时钟会一直运行此程序,获取RTC的时间,然后再显示。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/gMgKXAckuRbicKuddCKVAi25CIHMxDpYYdlOR7zx.png" alt="" width="884" height="457"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">     闹钟程序,当到达设定的闹钟时间后,闹钟开启时,开始执行此程序,闹钟响起。在for循环里面有一个按键检测语句,如果闹钟响起,则进入for循环,此时按下按键3,就可以关闭闹钟。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/LeYn4roCsSWT4Srextxf2Qh64X5d1VbWY4e0F59A.png" alt="" width="846" height="422"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">        蜂鸣器程序的编写,由于蜂鸣器是无源蜂鸣器,因此采用PWM驱动,先对PWM进行开启,再配置占空比,就可以进行驱动了,占空比大小决定声音大小,频率决定蜂鸣器音调。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> <img src="//image.lceda.cn/pullimage/Wfi5aTJgIDXXseH0bCHfQZRMlRN2b9bg39klue5J.png" alt="" width="910" height="702"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">        定时器回调函数,用于数码管的显示,主要是时间显示,以及修改其他设定时的显示等,定时刷新数码管。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> <img src="//image.lceda.cn/pullimage/JfXMJVhIOlSSMhRo4XghBGxgQZOSAaM5nAJauC8b.png" alt="" width="822" height="711"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">      变量声明,方便后面使用,以及外部声明的使用,便于其他源文件里引用。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/SbZAJj8G5xWZy1F0XpwFjG841SkoMOMJroDS5d7Z.png" alt=""></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">      数码管显示库函数,对需要用到的数字和字母写好对应的函数,后面可直接引用对应的函数显示对应的数字或字母。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/Ck2qtQjxHaU7kov30c6NmrCJUZKQ9KSRk9PKzBhK.png" alt="" width="887" height="725"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">       flash读取程序,在初始化中引用这个程序,就会在每次上电后,都会对flash里的数据进行读取。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/lWgSnMBhx89zOdaaiACEuypTET5NRn3vfQUUZ7tE.png" alt="" width="692" height="412"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">       flash写入程序,在对应的地址写入对应的数据。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/d8ROm9guLxSZQZyGaJpcgWAbYB5o819YaYlY49bL.png" alt="" width="795" height="658"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">       对DHT11传感器进行初始化,每次接收数据前,向传感器发送高低电平信号,等待接收来自传感器的数据。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/AnDF6FwF4ISFnctT1DTqCeXxXoqMX28e3qoEdkeu.png" alt=""></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">       DHT11传感器数据读取函数,对从DHT11收到的数据进行处理。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/Rk1lf7ygLCaRbDqv0RmePlxP4frdeagAYSnIGuvS.png" alt="" width="865" height="690"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p><span style="font-size:14px;color:#e03e2d;"><strong>注:以上是对瑞萨芯片程序的分析,下面是对esp01s模块程序的分析</strong></span></p> <p> </p> <p><span style="font-size:14px;color:#e03e2d;"><strong>    </strong><span style="color:#000000;">由于esp01s只用于获取时间,因此程序很简单。使用Arduino进行编写,下图是对一些库文件的引用,以及变量声明</span></span></p> <p><span style="font-size:14px;color:#e03e2d;">注:const char *ssid     = "   ";引号里填的是需要连接wifi的名称,const char *password = "     ";引号里填的是wifi密码。</span></p> <p><span style="font-size:14px;color:#000000;"><strong><img src="//image.lceda.cn/pullimage/JZR7Cd5VwmLAyzHNpPlgxmMpYaY9Xsno1FdsDnHc.png" alt="" width="753" height="312"></strong></span></p> <p> </p> <p> </p> <p><span style="font-size:14px;color:#000000;">       对串口初始化,以及需要执行的函数进行初始化(执行一次),先开启STA模式,连接需要连接的wifi,等待20S,如果20S未连接上设定的wifi,则开启AP模式,开启热点(智能时钟)供用户配置wifi,配置完成后连接用户配置的wifi</span></p> <p> </p> <p><span style="font-size:14px;color:#000000;"><strong><img src="//image.lceda.cn/pullimage/bOmL3r6PqsoGFu3HPI9GJ7DXpdbeqKGo43sCIqLs.png" alt="" width="754" height="541"></strong></span></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;">      主函数,每两分钟向串口发送一次时间数据;小时,分钟,秒,输出的数据都是两位,便于瑞萨芯片收到数据后进行处理。</p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/7ksqJ0iFfWt9STERmKrb3kL20XzLVDQSGEKPJ6DT.png" alt="" width="719" height="423"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*6、BOM清单</h3> <hr class="horizontal-splitline normal-bold-2"> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/9BIx9AZDdTjQCrEVFRAQOZI6Im18msf3ZdnsdAvb.png" alt="" width="635" height="341"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*7、大赛LOGO验证</h3> <p><strong>PCB正面</strong></p> <hr class="horizontal-splitline normal-bold-2"> <p style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/ArkK5T2DMkkZLOjc0OV1mjyGm9wg6uGAOVT71mlY.jpeg" alt="" width="559" height="332"></p> <p style="line-height:1.8;"> </p> <p style="line-height:1.8;"><strong>PCB反面</strong></p> <p style="line-height:1.8;"><img src="//image.lceda.cn/pullimage/XsR5F49U4Y91i2twW70htlG9epZw3jYM5G0NqjId.jpeg" alt="" width="559" height="316"></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 8、演示您的项目并录制成视频上传</h3> <hr class="horizontal-splitline normal-bold-2"> <p style="line-height:1.8;">    下面已上传演示视频,但由于大小限制,画质经过压缩后上传的,将高清视频放在了B站<a href="https://b23.tv/00oIpUl" target="_blank">【基于R7FA2E1A72DFL的数码管智能时钟-哔哩哔哩】</a></p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> <p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p> </div>

文档

BOM

暂无

附件

附件名 下载
智能时钟.mp4
BOM_Board_智能时钟.xlsx
代码资料.zip

成员

评论(9)

  • 表情
    emoji
    小嘉工作篇
    小嘉日常篇
  • 图片
成功
工程所有者当前已关闭评论
存在任意 回复
<p>LDO通电时发热严重吗?求解答(<em>^▽^</em>)</p>
lsjl66 回复
<p>不严重,用的是AP2112K,这个芯片仅给esp01s提供供电,而且是低压差,所以发热量一般,摸着没什么感觉</p>
yian123456 回复
<p>其实我简易用lcd1602,显示更全面</p>
lsjl66 回复
<p>确实,各有各的优势吧,这个主要是简单易懂</p>
立创电赛 回复
<p>点赞+收藏+评论赢500元京东E卡:<a href="https://diy.szlcsc.com/posts/9d4438cf6d3848d3a53c50e029514a91" target="_blank">https://diy.szlcsc.com/posts/9d4438cf6d3848d3a53c50e029514a91</a></p>
立创电赛 回复
<p>恭喜您在“瑞萨MCU杯”第八届立创电子设计开源大赛中获得优胜奖,更多详情见:<a href="https://diy.szlcsc.com/posts/9aea5131523341fbab0bb927c5c4c603" target="_blank">https://diy.szlcsc.com/posts/9aea5131523341fbab0bb927c5c4c603</a></p>
lsjl66 回复
<p>ap2112k这个LDO应该是3.3V的,bom里的1.2v有问题,不能用</p>
lsjl66 回复
<p>瑞萨芯片串口下载程序前,接好线后,连接芯片前需要同时按住复位按钮和BOOT按钮,一直按着BOOT按钮不放,然后松开复位按钮,再点连接即可</p>
lsjl66 回复
<p><img title="点击查看大图" src="//image.lceda.cn/pullimage/J1SHBFlHyogDgXG1JTAK8A5O3bftvwGhCZnLjxRX.webp"></p>
goToTop
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow