欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
運(yùn)用DS1307和1602 LCD制作電子時(shí)鐘
[打印本頁(yè)]
作者:
麒麟臂控制不住
時(shí)間:
2021-3-13 09:40
標(biāo)題:
運(yùn)用DS1307和1602 LCD制作電子時(shí)鐘
/*
DS1307和1602 LCD制作電子時(shí)鐘
*/
// 引用會(huì)使用到的四個(gè)庫(kù)文件
#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>
#include <LiquidCrystal.h>
// 實(shí)例化一個(gè)名為lcd的LiquidCrysta類型對(duì)象,并初始化相關(guān)引腳
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
// 設(shè)置LCD有幾列幾行,1602LCD為16列2行
lcd.begin(16, 2);
// 打印一段信息到LCD上
lcd.print("This is a Clock");
delay(3000);
lcd.clear();
}
void loop()
{
tmElements_t tm;
// 讀出DS1307中的時(shí)間數(shù)據(jù),并存入tm中
if (RTC.read(tm))
{
// 清除屏幕顯示內(nèi)容
lcd.clear();
//在LCD第一行輸出日期信息
lcd.setCursor(0, 0);
lcd.print(tmYearToCalendar(tm.Year));
lcd.print("-");
lcd.print(tm.Month);
lcd.print("-");
lcd.print(tm.Day);
//在LCD第二行輸出時(shí)間信息
lcd.setCursor(8, 1);
lcd.print(tm.Hour);
lcd.print(":");
lcd.print(tm.Minute);
lcd.print(":");
lcd.print(tm.Second);
}
// 如果讀取數(shù)據(jù)失敗,則輸出錯(cuò)誤提示
else
{
lcd.setCursor(0, 1);
lcd.print("error");
}
//每秒鐘更新一次顯示內(nèi)容
delay(1000);
}
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1