#include "RTClib.h"

RTC_DS1307 rtc;

// Inisialisasi Jumlah LED
const int numLED = 4;
// LED 1,2,3 jadi 1 varibel
// dengaan alamat index 0,1,2
const int pinLED[numLED] = {8,9,10};

//inisialisasi hari dalam seminggu
char daysOfTheWeek[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};

void setup () {
  Serial.begin(115200);

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }
  // Inisialisasi semua pin LED sebagai OUTPUT
  for(int i=0; i<3; i++){
    pinMode(pinLED[i], OUTPUT);
  }
}

void loop () {
  DateTime now = rtc.now();
  for(int i=0; i<3; i++){
    digitalWrite(pinLED[i], LOW);
  }
    delay(500);
  for(int i=0; i<3; i++){
    digitalWrite(pinLED[i], HIGH);
    delay(500);
  }
  Serial.print("Current time: ");
  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();
  Serial.println();
  delay(10000);
  
  // Hidupkan semua LED bertahap dg jeda 1 detik
}


GND5VSDASCLSQWRTCDS1307+