#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Wire.h>
#include <RTClib.h>
#define TFT_CS 10
#define TFT_DC 9
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
RTC_DS3231 rtc;
void setup() {
Serial.begin(9600);
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, let's set the time!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
tft.begin();
tft.setRotation(4); // Adjust the rotation if needed
tft.fillScreen(ILI9341_BLACK); // Clear the TFT display
}
void loop() {
DateTime now = rtc.now();
// Format the time as a string
String timeStr = now.toString("hh:mm:ss");
// Clear previous time on TFT display
tft.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ILI9341_BLACK);
// Display time on TFT display
tft.setCursor(0, 100);
tft.setTextSize(5);
tft.setTextColor(ILI9341_RED);
tft.print(timeStr);
delay(3000); // Update every second
}
अरविंद चे घडयाळ दर दोन सेकंद झाल्यावर वेळ दाखविते
अरविन्द पाटील 21/11/23 .
by arvind 20/11/23.