“SKU:RB-02S101 RTC時鐘模塊”的版本間的差異
來自ALSROBOT WiKi
(→?產(chǎn)品相關推薦) |
|||
(未顯示1個用戶的18個中間版本) | |||
第1行: | 第1行: | ||
? | [[文件: | + | [[文件:RB02S1010111.png|500px|縮略圖|右]] |
==產(chǎn)品概述== | ==產(chǎn)品概述== | ||
? | + | RTC 時鐘模塊是一款低功耗,具有 56 字節(jié)非失性 RAM 的全 BCD 碼時鐘日歷實時時鐘模塊,芯片可以提供秒,分,小時等信息,每一個月的天數(shù)能自動調(diào)整。并且有閏年補償功能。AM/PM 標志位決定時鐘工作于 24 小時或 12 小時模式,芯片有一個內(nèi)置的電源感應電路,具有掉電檢測和電池切換功能。當單片機斷電情況下,可以通過一個電池讓單片機項目時間保持記錄,完善的數(shù)據(jù)記錄。 | |
==規(guī)格參數(shù)== | ==規(guī)格參數(shù)== | ||
? | # | + | # 產(chǎn)品貨號:RB-02S101 |
? | # | + | # 工作電壓:DC 5V |
# 主控芯片:DS1307 | # 主控芯片:DS1307 | ||
+ | # 晶振頻率:32.768 KHz | ||
# 工作溫度范圍:0°C to +70°C | # 工作溫度范圍:0°C to +70°C | ||
# 接口類型:IIC 通信接口 | # 接口類型:IIC 通信接口 | ||
+ | # 配套電池型號:3V CR1220 紐扣電池 | ||
# 固定孔:4個 * M3 | # 固定孔:4個 * M3 | ||
# 產(chǎn)品尺寸:45mm * 25mm | # 產(chǎn)品尺寸:45mm * 25mm | ||
+ | |||
+ | * 產(chǎn)品尺寸圖: | ||
+ | [[文件:size032.jpg|600px|縮略圖|居中]] | ||
+ | |||
==接口定義== | ==接口定義== | ||
RTC時鐘模塊引腳定義: | RTC時鐘模塊引腳定義: | ||
第16行: | 第22行: | ||
* +:電源(VCC) | * +:電源(VCC) | ||
* -:地(GND) | * -:地(GND) | ||
? | == | + | |
+ | ==使用方法1(Arduino 控制器)== | ||
+ | ===使用硬件=== | ||
+ | * Arduino UNO 控制器 | ||
+ | * RTC 時鐘模塊 | ||
+ | * USB 數(shù)據(jù)線 | ||
+ | * 杜邦線若干 | ||
+ | |||
===硬件連接=== | ===硬件連接=== | ||
[[文件:RB02S10102.png|700px|縮略圖|居中]] | [[文件:RB02S10102.png|700px|縮略圖|居中]] | ||
? | === | + | ===Arduino_code_1=== |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
<pre style='color:blue'> | <pre style='color:blue'> | ||
? | |||
#include <Wire.h> | #include <Wire.h> | ||
#include "RTClib.h" | #include "RTClib.h" | ||
? | |||
? | |||
? | |||
? | |||
? | |||
RTC_DS1307 rtc; | RTC_DS1307 rtc; | ||
第42行: | 第43行: | ||
void setup () { | void setup () { | ||
? | |||
? | |||
? | |||
? | |||
? | |||
Serial.begin(57600); | Serial.begin(57600); | ||
if (! rtc.begin()) { | if (! rtc.begin()) { | ||
第55行: | 第51行: | ||
if (! rtc.isrunning()) { | if (! rtc.isrunning()) { | ||
Serial.println("RTC is NOT running!"); | 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 () { | void loop () { | ||
? | DateTime now = rtc.now(); | + | DateTime now = rtc.now(); |
+ | |||
Serial.print(now.year(), DEC); | Serial.print(now.year(), DEC); | ||
Serial.print('/'); | Serial.print('/'); | ||
第78行: | 第73行: | ||
Serial.print(now.second(), DEC); | Serial.print(now.second(), DEC); | ||
Serial.println(); | Serial.println(); | ||
+ | |||
delay(3000); | delay(3000); | ||
? | }</pre> | + | } |
+ | </pre> | ||
===程序效果=== | ===程序效果=== | ||
[[文件:RB02S10103.png|420px|縮略圖|居中]] | [[文件:RB02S10103.png|420px|縮略圖|居中]] | ||
+ | |||
+ | ==使用方法2(Arduino 控制器)== | ||
+ | ===使用硬件=== | ||
+ | * Arduino UNO R3 控制器 * 1 個 | ||
+ | * V5.0 傳感器擴展板 * 1 個 | ||
+ | * 四位七段數(shù)碼管 * 1 個 | ||
+ | * RTC 時鐘模塊 * 1 個 | ||
+ | * 傳感器連接線若干 | ||
+ | |||
+ | ===硬件連接=== | ||
+ | [[文件:RB05L021100.png|600px|縮略圖|居中]] | ||
+ | ===Arduino_code_2=== | ||
+ | <pre style='color:blue'> | ||
+ | #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; | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | ===程序效果=== | ||
+ | 數(shù)碼管實時電子時鐘。 | ||
==產(chǎn)品相關推薦== | ==產(chǎn)品相關推薦== | ||
[[文件:erweima.png|230px|無框|右]] | [[文件:erweima.png|230px|無框|右]] | ||
+ | ===資料下載=== | ||
+ | 例程下載鏈接: https://pan.baidu.com/s/17MEoniYbgygkhcAB5iAqSQ 提取碼:tsyj | ||
===產(chǎn)品購買地址=== | ===產(chǎn)品購買地址=== | ||
? | [http://gharee.com/goods- | + | [http://gharee.com/goods-767.html RTC 時鐘模塊]<br/> |
+ | |||
===周邊產(chǎn)品推薦=== | ===周邊產(chǎn)品推薦=== | ||
[http://gharee.com/goods-130.html 串行1602液晶顯示模塊]<br/> | [http://gharee.com/goods-130.html 串行1602液晶顯示模塊]<br/> |
2021年7月21日 (三) 10:05的最后版本
目錄 |
產(chǎn)品概述
RTC 時鐘模塊是一款低功耗,具有 56 字節(jié)非失性 RAM 的全 BCD 碼時鐘日歷實時時鐘模塊,芯片可以提供秒,分,小時等信息,每一個月的天數(shù)能自動調(diào)整。并且有閏年補償功能。AM/PM 標志位決定時鐘工作于 24 小時或 12 小時模式,芯片有一個內(nèi)置的電源感應電路,具有掉電檢測和電池切換功能。當單片機斷電情況下,可以通過一個電池讓單片機項目時間保持記錄,完善的數(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)品相關推薦
資料下載
例程下載鏈接: https://pan.baidu.com/s/17MEoniYbgygkhcAB5iAqSQ 提取碼:tsyj
產(chǎn)品購買地址
周邊產(chǎn)品推薦
串行1602液晶顯示模塊
1602液晶擴展板 v2.0 Arduino LCD 1602 Keypad Shield
Arduino四位七段數(shù)碼管