arduino-ds1302 时间显示问题
麻烦求助一下,网上下载的样例,但是读取的时候会有乱码,试了好几个例子都是这样,请教一下大家这是为什么?谢谢!#include <DS1302.h>
// Init the DS1302
DS1302 rtc(2, 3, 7);
void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// Setup Serial connection
Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
// rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(6, 8, 2013); // Set the date to August 6th, 2010
}
void loop()
{
// Send Day-of-Week
Serial.print(rtc.getDOWStr());
Serial.print(" ");
// Send date
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
// Send time
Serial.println(rtc.getTimeStr());
// Wait one second before repeating :)
delay (1000);
}
本帖最后由 275891381 于 2016-8-8 18:20 编辑
库文件有问题,发下我给你看看
uint8_t DS1302::seconds()
{
return _register_bcd_to_dec(SEC_REG, 6);
}
uint8_t DS1302::minutes()
{
return _register_bcd_to_dec(MIN_REG);
}
改成下面试试
uint8_t DS1302::seconds()
{
return _register_bcd_to_dec(SEC_REG, 6);
}
uint8_t DS1302::minutes()
{
return _register_bcd_to_dec(MIN_REG,6);
} 275891381 发表于 2016-8-8 18:18 static/image/common/back.gif
库文件有问题,发下我给你看看
uint8_t DS1302::seconds()
{
你好库文件是修改哪个呀。。。。。? 本帖最后由 275891381 于 2016-8-9 08:04 编辑
wyl_stloy 发表于 2016-8-9 00:02 static/image/common/back.gif
你好库文件是修改哪个呀。。。。。?
这么空说,谁知道修改哪个
这个肯定可以用
页:
[1]