SKU:RB-02S101 RTC時(shí)鐘模塊
來(lái)自ALSROBOT WiKi
目錄 |
產(chǎn)品概述
RTC 時(shí)鐘模塊是一款低功耗,具有 56 字節(jié)非失性 RAM 的全 BCD 碼時(shí)鐘日歷實(shí)時(shí)時(shí)鐘模塊,芯片可以提供秒,分,小時(shí)等信息,每一個(gè)月的天數(shù)能自動(dòng)調(diào)整。并且有閏年補(bǔ)償功能。AM/PM 標(biāo)志位決定時(shí)鐘工作于 24 小時(shí)或 12 小時(shí)模式,芯片有一個(gè)內(nèi)置的電源感應(yīng)電路,具有掉電檢測(cè)和電池切換功能。當(dāng)單片機(jī)斷電情況下,可以通過(guò)一個(gè)電池讓單片機(jī)項(xiàng)目時(shí)間保持記錄,完善的數(shù)據(jù)記錄。
規(guī)格參數(shù)
- 產(chǎn)品貨號(hào):RB-02S101
- 工作電壓:DC 5V
- 主控芯片:DS1307
- 晶振頻率:32.768 KHz
- 工作溫度范圍:0°C to +70°C
- 接口類(lèi)型:IIC 通信接口
- 配套電池型號(hào):3V CR1220 紐扣電池
- 固定孔:4個(gè) * M3
- 產(chǎn)品尺寸:45mm * 25mm
- 產(chǎn)品尺寸圖:
接口定義
RTC時(shí)鐘模塊引腳定義:
- SDA:I2C 數(shù)據(jù)引腳
- SCK:I2C 時(shí)鐘引腳
- +:電源(VCC)
- -:地(GND)
使用方法1(Arduino 控制器)
使用硬件
- Arduino UNO 控制器
- RTC 時(shí)鐘模塊
- USB 數(shù)據(jù)線
- 杜邦線若干
硬件連接
Arduino_code_1
#include <Wire.h> #include "RTClib.h" RTC_DS1307 rtc; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; void setup () { Serial.begin(57600); if (! rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } if (! rtc.isrunning()) { Serial.println("RTC is NOT running!"); rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); //獲取電腦的系統(tǒng)時(shí)間 // rtc.adjust(DateTime(2017, 4, 2, 13, 57, 0)); } } void loop () { DateTime now = rtc.now(); Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(" ("); Serial.print(daysOfTheWeek[now.dayOfTheWeek()]); Serial.print(") "); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); delay(3000); }
程序效果
使用方法2(Arduino 控制器)
使用硬件
- Arduino UNO R3 控制器 * 1 個(gè)
- V5.0 傳感器擴(kuò)展板 * 1 個(gè)
- 四位七段數(shù)碼管 * 1 個(gè)
- RTC 時(shí)鐘模塊 * 1 個(gè)
- 傳感器連接線若干
硬件連接
Arduino_code_2
#include <TimerOne.h> #include "TM1637.h" #include <Wire.h> #include "RTClib.h" #define ON 1 #define OFF 0 RTC_DS1307 rtc; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int8_t TimeDisp[] = {0x00,0x00,0x00,0x00}; unsigned char ClockPoint = 1; unsigned char Update; unsigned char minute = 0; unsigned char hour = 12; int stem,val; #define CLK 5 #define DIO 4 TM1637 tm1637(CLK,DIO); void setup() { tm1637.set(); tm1637.init(); Timer1.initialize(500000); Timer1.attachInterrupt(TimingISR); Serial.begin(57600); if (! rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } if (! rtc.isrunning()) { Serial.println("RTC is NOT running!"); rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); //獲取電腦的系統(tǒng)時(shí)間 // rtc.adjust(DateTime(2017, 4, 2, 13, 57, 0)); } } void loop() { DateTime now = rtc.now(); if(Update == ON) { TimeUpdate(); tm1637.display(TimeDisp); } stem = now.hour(); val = now.minute(); } void TimingISR() { ClockPoint = (~ClockPoint) & 0x01; Update = ON; } void TimeUpdate(void) { if(ClockPoint)tm1637.point(POINT_ON); else tm1637.point(POINT_OFF); TimeDisp[0] = stem/ 10; TimeDisp[1] = stem % 10; TimeDisp[2] = val / 10; TimeDisp[3] = val % 10; }
程序效果
數(shù)碼管實(shí)時(shí)電子時(shí)鐘。
產(chǎn)品相關(guān)推薦
資料下載
例程下載鏈接: https://pan.baidu.com/s/17MEoniYbgygkhcAB5iAqSQ 提取碼:tsyj
產(chǎn)品購(gòu)買(mǎi)地址
周邊產(chǎn)品推薦
串行1602液晶顯示模塊
1602液晶擴(kuò)展板 v2.0 Arduino LCD 1602 Keypad Shield
Arduino四位七段數(shù)碼管