/*** 範例 11.4.1(I2C 範例-1) ***/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
LiquidCrystal_I2C *myLCD;
RTC_DS1307 RTC;

byte addr; 
/***************************************************
 * setup
 ***************************************************/
void setup() {
 Serial.begin(9600); //設定串列埠傳輸速率為 9600 bps
 Wire.begin(); //將本裝置初始成 master
 Serial.println("I2C Slave Scanning ...");
 for(byte addr=8;addr<120;addr++) { //從位址 8 開始掃瞄到位址 119
    Wire.beginTransmission(addr); //開始傳送資料到指定的 slave 位址
   if(Wire.endTransmission()==0) { //假如有回傳 ACK 就顯示其位址
    Serial.print("Find slave at: 0X");
    Serial.println(addr, HEX);
    break;
    }
  }
 Serial.println("End ...");
 RTC.begin();
 myLCD = new LiquidCrystal_I2C ((uint8_t)addr, 16, 2);
 myLCD->init();
 myLCD->backlight();
 myLCD->setCursor(2,0);
 myLCD->print("Hello");
} /***************************************************
 * loop
 ***************************************************/
void loop() {
  DateTime now = RTC.now();
  myLCD -> setCursor(0,0); myLCD -> print("DATE: ");
  myLCD -> print(now.year());myLCD -> print("/");myLCD -> print(now.month());myLCD -> print("/");myLCD -> print(now.day());
  myLCD -> setCursor(0,1); myLCD -> print("TIME: ");
  myLCD -> print(now.hour());myLCD -> print(":");myLCD -> print(now.minute());myLCD -> print(":");myLCD -> print(now.second());
  
  }
D0D1D2D3D4D5D6D7GNDLOGIC
GND5VSDASCLSQWRTCDS1307+