标题:
DS1307 RTC时钟芯片实验
[打印本页]
作者:
爱生活学习
时间:
2018-10-11 11:58
标题:
DS1307 RTC时钟芯片实验
实验器件 :
Arduino 控制板 1 块、USB 数据线 1 根、面包板 1 块、面包板专用跳线 1 盒、镊子 1 把、DS1307 RTC 模块。
实验电路:
DS1307 RTC时钟芯片.png
(65.62 KB, 下载次数: 105)
下载附件
创客集结号
2018-10-11 11:58 上传
想了解更多创客知识,欢迎加入QQ群:820685901,或关注创客集结号。
实验原理 :
本程序需要用电脑来接收 arduino 传回的数据,需要点击打开串口监视器。
Arduino 代码 :
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
int rtc[7];
int ledPin = 13;
void setup()
{
DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd
PORTC |=_BV(3); // VCC PINC3
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
RTC.stop();
RTC.set(DS1307_SEC,1);
RTC.set(DS1307_MIN,57);
RTC.set(DS1307_HR,17);
RTC.set(DS1307_DOW,2);
RTC.set(DS1307_DATE,18);
RTC.set(DS1307_MTH,1);
RTC.set(DS1307_YR,10);
RTC.start();
}
void loop()
{
RTC.get(rtc,true);
for(int i=0; i<7; i++){
Serial.print(rtc[i]);
Serial.print(" ");
}
Serial.println();
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
复制代码
作者:
redtxd
时间:
2018-10-17 14:09
老师好,怎么通过按钮来设置DS1307的时间呢?谢谢!
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1