极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8748|回复: 0

如何使用ds1307用按键调时

[复制链接]
发表于 2012-11-8 17:15:37 | 显示全部楼层 |阅读模式
就是想用按键校时,不知道那里加这个按键,我加了好多地方都不能实现
  1. #include <WProgram.h>
  2. #include <Wire.h>
  3. #include <DS1307.h>

  4. int rtc[7];
  5. int ledPin =  13;
  6. void setup()
  7. {
  8.   DDRC|=_BV(2) |_BV(3);  // POWER:Vcc Gnd
  9.   PORTC |=_BV(3);  // VCC PINC3
  10.   pinMode(ledPin, OUTPUT);  
  11.   Serial.begin(9600);

  12.   RTC.stop();
  13.   RTC.set(DS1307_SEC,1);
  14.   RTC.set(DS1307_MIN,57);
  15.   RTC.set(DS1307_HR,17);
  16.   RTC.set(DS1307_DOW,2);
  17.   RTC.set(DS1307_DATE,18);
  18.   RTC.set(DS1307_MTH,1);
  19.   RTC.set(DS1307_YR,10);
  20.   RTC.start();
  21. }

  22. void loop()
  23. {
  24.   RTC.get(rtc,true);

  25.   for(int i=0; i<7; i++)
  26.   {
  27.     Serial.print(rtc[i]);
  28.     Serial.print(" ");
  29.   }
  30.   Serial.println();
  31.         digitalWrite(ledPin, HIGH);
  32.         delay(500);
  33.         digitalWrite(ledPin, LOW);
  34.         delay(500);
  35. }
复制代码
回复

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-29 22:06 , Processed in 0.054146 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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