#include #include #include #include #include // OLED settings #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // DS1302 setup ThreeWire myWire(7, 6, 8); // DAT, CLK, RST RtcDS1302 Rtc(myWire); void setup() { Serial.begin(9600); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.setTextColor(SSD1306_WHITE); display.setTextSize(1); display.setCursor(0, 0); display.println("Erbil Clock Starting..."); display.display(); delay(1500); Rtc.Begin(); // ⚠️ Set Erbil time ONCE (24-hour format), then comment this block out: RtcDateTime compiled = RtcDateTime(2025, 10, 13, 17, 18, 0); // YYYY,MM,DD,HH,MM,SS Rtc.SetDateTime(compiled); // ---- After uploading once, comment these 2 lines and upload again ---- } void loop() { RtcDateTime now = Rtc.GetDateTime(); int hour = now.Hour(); int minute = now.Minute(); int second = now.Second(); // Convert to 12-hour format int displayHour = hour % 12; if (displayHour == 0) displayHour = 12; const char* ampm = (hour >= 12) ? "PM" : "AM"; // Format time string char timeBuf[12]; sprintf(timeBuf, "%02d:%02d:%02d %s", displayHour, minute, second, ampm); // Show on OLED display.clearDisplay(); display.setTextSize(2); display.setCursor(10, 20); display.print(timeBuf); display.setTextSize(1); display.setCursor(40, 50); display.print("Erbil Time"); display.display(); delay(500); }