SKU:RB-02S101 RTC時鐘模塊
來自ALSROBOT WiKi
目錄 |
產(chǎn)品概述
RTC 時鐘模塊是一款低功耗,具有 56 字節(jié)非失性 RAM 的全 BCD 碼時鐘日歷實時時鐘模塊,芯片可以提供秒,分,小時等信息,每一個月的天數(shù)能自動調(diào)整。并且有閏年補償功能。AM/PM 標(biāo)志位決定時鐘工作于 24 小時或 12 小時模式,芯片有一個內(nèi)置的電源感應(yīng)電路,具有掉電檢測和電池切換功能。當(dāng)單片機斷電情況下,可以通過一個電池讓單片機項目時間保持記錄,完善的數(shù)據(jù)記錄。
規(guī)格參數(shù)
- 產(chǎn)品貨號:RB-02S101
- 工作電壓:DC 5V
- 主控芯片:DS1307
- 晶振頻率:32.768 KHz
- 工作溫度范圍:0°C to +70°C
- 接口類型:IIC 通信接口
- 配套電池型號:3V CR1220 紐扣電池
- 固定孔:4個 * M3
- 產(chǎn)品尺寸:45mm * 25mm
- 產(chǎn)品尺寸圖:
接口定義
RTC時鐘模塊引腳定義:
- SDA:I2C 數(shù)據(jù)引腳
- SCK:I2C 時鐘引腳
- +:電源(VCC)
- -:地(GND)
使用方法1(Arduino 控制器)
使用硬件
- Arduino UNO 控制器
- RTC 時鐘模塊
- 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)時間 // 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 個
- V5.0 傳感器擴展板 * 1 個
- 四位七段數(shù)碼管 * 1 個
- RTC 時鐘模塊 * 1 個
- 傳感器連接線若干
硬件連接
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)時間 // 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ù)碼管實時電子時鐘。
產(chǎn)品相關(guān)推薦
資料下載
例程下載鏈接:https://pan.baidu.com/s/1g-jc2ke3M-0GVUPVr4AmnQ 密碼:2yd3
產(chǎn)品購買地址
周邊產(chǎn)品推薦
串行1602液晶顯示模塊
1602液晶擴展板 v2.0 Arduino LCD 1602 Keypad Shield
Arduino四位七段數(shù)碼管