#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define BUTTON_PIN 2
#define BUZZER_PIN 4
#define LED_PIN 3
LiquidCrystal_I2C lcd(0x27, 16, 2);
// أسماء أيام الأسبوع
const char* daysOfWeek[7] = {“Friday”, “Saturday”, “Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”};
// جدول التذكيرات مع تقسيم الفترات إلى نصف ساعة
const char* dailyReminders[7][5][2] = {
{{“5:00-5:15AM”, “Pray Fajr at time”}, {“7:00-7:15AM”, “Read Surah Kahf”}, {“12:00-12:15PM”, “Go to Jumuah”}, {“3:00-3:15PM”, “Make sincere Dua”}, {“8:00-8:15PM”, “Call your family”}},
{{“6:00-6:15AM”, “Stretch your body”}, {“7:00-7:15AM”, “Recite Quran”}, {“8:00-4:00PM”, “Focus on work”}, {“6:00-6:15PM”, “Take a long walk”}, {“9:00-9:15PM”, “Look at the stars”}},
{{“6:00-6:15AM”, “Pray Duha Sunnah”}, {“7:00-7:15AM”, “Study a Hadith”}, {“8:00-4:00PM”, “Work with effort”}, {“6:00-6:15PM”, “Jog outside”}, {“8:00-8:15PM”, “Watch the moon”}},
{{“6:00-6:15AM”, “Say morning Dhikr”}, {“7:00-7:15AM”, “Read a good book”}, {“8:00-4:00PM”, “Give best at work”}, {“6:00-6:15PM”, “Do your workout”}, {“8:00-8:15PM”, “Enjoy nature”}},
{{“5:00-5:15AM”, “Pray Fajr early”}, {“7:00-7:15AM”, “Memorize some Ayahs”}, {“8:00-4:00PM”, “Work with focus”}, {“6:00-6:15PM”, “Drink more water”}, {“8:00-8:15PM”, “Call your parents”}},
{{“5:00-5:15AM”, “Go to mosque”}, {“7:00-7:15AM”, “Organize your room”}, {“8:00-4:00PM”, “Be productive”}, {“6:00-6:15PM”, “Take a short walk”}, {“9:00-9:15PM”, “Observe the stars”}},
{{“6:00-6:15AM”, “Make long Dua”}, {“7:00-7:15AM”, “Reflect on life”}, {“8:00-4:00PM”, “Work smartly”}, {“6:00-6:15PM”, “Do some squats”}, {“8:00-8:15PM”, “Listen to Quran”}}
};
int currentDay = 0;
unsigned long lastUpdateTime = 0;
const unsigned long dayDuration = 86400000;
unsigned long lastReminderTime = 0;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
lcd.init();
lcd.backlight();
selectDayManually();
lastUpdateTime = millis();
lastReminderTime = millis();
showStartMessage();
}
void loop() {
if (millis() – lastUpdateTime >= dayDuration) {
currentDay = (currentDay + 1) % 7;
EEPROM.write(0, currentDay);
lastUpdateTime = millis();
}
if (digitalRead(BUTTON_PIN) == LOW) {
delay(200);
while (digitalRead(BUTTON_PIN) == LOW);
showReminders();
}
}
void showReminders() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Day: “);
lcd.print(daysOfWeek[currentDay]);
delayWithLoop(2000);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 3; j++) {
digitalWrite(LED_PIN, HIGH);
tone(BUZZER_PIN, 1000);
delayWithLoop(200);
digitalWrite(LED_PIN, LOW);
noTone(BUZZER_PIN);
delayWithLoop(200);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(dailyReminders[currentDay][i][0]);
scrollText(dailyReminders[currentDay][i][1], 5000);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“All Done!”);
lcd.setCursor(0, 1);
lcd.print(“Keep Going!”);
delayWithLoop(2000);
showStartMessage();
}
void showStartMessage() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Press button”);
lcd.setCursor(0, 1);
lcd.print(“for reminders”);
}
void selectDayManually() {
int selectedDay = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Select Day:”);
while (true) {
lcd.setCursor(0, 1);
lcd.print(” “);
lcd.setCursor(0, 1);
lcd.print(daysOfWeek[selectedDay]);
unsigned long startTime = millis();
bool buttonPressed = false;
while (millis() – startTime < 3000) {
if (digitalRead(BUTTON_PIN) == LOW) {
delay(200);
while (digitalRead(BUTTON_PIN) == LOW);
buttonPressed = true;
break;
}
}
if (buttonPressed) {
for (int i = 0; i < 5; i++) { // وميض LED وصوت
digitalWrite(LED_PIN, HIGH);
tone(BUZZER_PIN, 1000);
delay(200);
digitalWrite(LED_PIN, LOW);
noTone(BUZZER_PIN);
delay(200);
}
currentDay = selectedDay;
EEPROM.write(0, currentDay);
break;
}
selectedDay = (selectedDay + 1) % 7;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Day Selected:”);
lcd.setCursor(0, 1);
lcd.print(daysOfWeek[currentDay]);
delayWithLoop(2000);
}
void delayWithLoop(int duration) {
for (int i = 0; i < duration / 10; i++) {
delay(10);
}
}
void scrollText(const char* text, int displayTime) {
int len = strlen(text);
unsigned long startTime = millis();
if (len <= 16) {
lcd.setCursor(0, 1);
lcd.print(text);
delayWithLoop(displayTime);
} else {
char buffer[17];
int start = 0;
while (millis() – startTime < displayTime) {
strncpy(buffer, text + start, 16);
buffer[16] = ‘\0’;
lcd.setCursor(0, 1);
lcd.print(buffer);
delayWithLoop(500);
start++;
if (start > len – 16) {
start = 0;
}
}
}
}