极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 13477|回复: 2

ds1302 顯示問題

[复制链接]
发表于 2015-2-4 15:09:03 | 显示全部楼层 |阅读模式
我從http://www.henningkarlsen.com/electronics/library.php?id=5  下載library
用範例內建DS1302_Serial_Easy做做看
發現Serial Monitor 秒數怪怪的
似乎每隔好幾秒才會更新一次

  1. // DS1302_Serial_Easy (C)2010 Henning Karlsen
  2. // web: http://www.henningkarlsen.com/electronics
  3. //
  4. // A quick demo of how to use my DS1302-library to
  5. // quickly send time and date information over a serial link
  6. //
  7. // I assume you know how to connect the DS1302.
  8. // DS1302:  CE pin    -> Arduino Digital 2
  9. //          I/O pin   -> Arduino Digital 3
  10. //          SCLK pin  -> Arduino Digital 4

  11. #include <DS1302.h>

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

  14. void setup()
  15. {
  16.   // Set the clock to run-mode, and disable the write protection
  17.   rtc.halt(false);
  18.   rtc.writeProtect(false);
  19.   
  20.   // Setup Serial connection
  21.   Serial.begin(9600);

  22.   // The following lines can be commented out to use the values already stored in the DS1302
  23.   rtc.setDOW(FRIDAY);        // Set Day-of-Week to FRIDAY
  24.   rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
  25.   rtc.setDate(6, 8, 2010);   // Set the date to August 6th, 2010
  26. }

  27. void loop()
  28. {
  29.   // Send Day-of-Week
  30.   Serial.print(rtc.getDOWStr());
  31.   Serial.print(" ");
  32.   
  33.   // Send date
  34.   Serial.print(rtc.getDateStr());
  35.   Serial.print(" -- ");

  36.   // Send time
  37.   Serial.println(rtc.getTimeStr());
  38.   
  39.   // Wait one second before repeating :)
  40.   delay (1000);
  41. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2016-10-18 11:57:48 | 显示全部楼层
你的图和你的程序不符;

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

但是COM口显示的却是2015.02.04—9:0:0
回复 支持 反对

使用道具 举报

发表于 2016-10-18 20:25:34 | 显示全部楼层
还有你把delay(1000),去掉看看多久更新一次
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-13 23:03 , Processed in 0.043424 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表