30 DS1307時鐘模塊 Tiny RTC I2C模塊(探測傳感器類, IIC/I2C接口)
- #include <Wire.h>
- #include <RTClib.h>
-
- DS1307 RTC;
-
- void setup () {
- Serial.begin(57600);
- Wire.begin();
- RTC.begin();
- RTC.adjust(DateTime(__DATE__, __TIME__));
- }
-
- 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(now.hour(), DEC);
- Serial.print(':');
- Serial.print(now.minute(), DEC);
- Serial.print(':');
- Serial.print(now.second(), DEC);
- Serial.println();
- delay(3000);
- }
復制代碼
|