cools0607 发表于 2015-2-4 15:09:03

ds1302 顯示問題

我從http://www.henningkarlsen.com/electronics/library.php?id=5下載library
用範例內建DS1302_Serial_Easy做做看
發現Serial Monitor 秒數怪怪的
似乎每隔好幾秒才會更新一次
// DS1302_Serial_Easy (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// A quick demo of how to use my DS1302-library to
// quickly send time and date information over a serial link
//
// I assume you know how to connect the DS1302.
// DS1302:CE pin    -> Arduino Digital 2
//          I/O pin   -> Arduino Digital 3
//          SCLK pin-> Arduino Digital 4

#include <DS1302.h>

// Init the DS1302
DS1302 rtc(2, 3, 4);

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, 2010);   // 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);
}

Joyce 发表于 2016-10-18 11:57:48

你的图和你的程序不符;

你的程序设置的时间是2010.8.6—12:0:0

但是COM口显示的却是2015.02.04—9:0:0

275891381 发表于 2016-10-18 20:25:34

还有你把delay(1000),去掉看看多久更新一次
页: [1]
查看完整版本: ds1302 顯示問題