Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Task Reminder System with RTC DS3231 and I2C LCD

View and Edit Project In Cirkit DesignerImage of Arduino UNO Task Reminder System with RTC DS3231 and I2C LCD

Circuit Documentation

Summary

This circuit is a Task Reminder System that uses an Arduino UNO microcontroller to manage tasks and remind the user at specific times. The system includes an RTC DS3231 for real-time clock functionality, a 16x2 I2C LCD for displaying task information, a pushbutton for user interaction, a buzzer for audible alerts, and an LED for visual alerts.

Component List

RTC DS3231

16x2 I2C LCD

Arduino UNO

LED: Two Pin (green)

Buzzer

Pushbutton

Wiring Details

RTC DS3231

16x2 I2C LCD

Arduino UNO

LED: Two Pin (green)

Buzzer

Pushbutton

Code Documentation

#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>

RTC_DS3231 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2);  // Change the I2C address if necessary

const int buzzerPin = 3;
const int ledPin = 2;
const int buttonPin = 4;
bool taskActive = false;
bool taskDismissed[10];  // Array to track dismissed tasks
int lastTaskIndex = -1;  // Track the last active task

const int numTasks = 10;  // Number of tasks per day

// Task times (hours and minutes) in 24-hour format
int taskHours[numTasks] = {7, 8, 9, 10, 11, 12, 14, 16, 18, 20};
int taskMinutes[numTasks] = {30, 0, 30, 0, 30, 0, 0, 0, 0, 30};

// Task descriptions
String tasks[numTasks] = {
  "Breakfast",
  "Take Medication",
  "Morning Walk",
  "Snack Time",
  "Read a Book",
  "Lunch",
  "Afternoon Nap",
  "Exercise",
  "Dinner",
  "Prepare for Bed"
};

int lastDay = -1;  // Keep track of the last day to reset tasks

void setup() {
  Serial.begin(9600);
  Serial.println("Initializing Task Reminder System...");
  
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
  
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1); // Halt if RTC doesn't start
  }

  lcd.init();
  lcd.begin(16,2);
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Task Reminder Sys");
  delay(2000);

  for (int i = 0; i < numTasks; i++) {
    taskDismissed[i] = false;
  }

  Serial.println("System Initialized!");
}

void loop() {
  DateTime now = rtc.now();
  Serial.print("Current Time: ");
  Serial.print(now.hour());
  Serial.print(":");
  Serial.println(now.minute());

  if (now.day() != lastDay) {
    lastDay = now.day();
    resetTaskDismissal();
  }

  for (int i = 0; i < numTasks; i++) {
    if (!taskDismissed[i] && now.hour() == taskHours[i] && now.minute() == taskMinutes[i]) {
      taskActive = true;
      triggerTaskAlert(i);
    }
  }

  // Check if the task is active and if the button is pressed to dismiss it
  static unsigned long lastDebounceTime = 0;
  const unsigned long debounceDelay = 50; // Adjust as needed
  if (taskActive && (millis() - lastDebounceTime) > debounceDelay) {
    if (digitalRead(buttonPin) == LOW) {
      lastDebounceTime = millis();
      taskActive = false;
      taskDismissed[lastTaskIndex] = true;
      dismissTask();
    }
  }
}

void triggerTaskAlert(int taskIndex) {
  lastTaskIndex = taskIndex;
  digitalWrite(ledPin, HIGH);
  tone(buzzerPin, 1000);
  displayTaskReminder(taskIndex);
  Serial.print("Task Alert: ");
  Serial.println(tasks[taskIndex]);
}

void displayTaskReminder(int taskIndex) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(tasks[taskIndex]);
  lcd.setCursor(0, 1);
  lcd.print("Press Btn to Dismiss");
  Serial.println("Reminder Displayed on LCD");
}

void resetTaskDismissal() {
  for (int i = 0; i < numTasks; i++) {
    taskDismissed[i] = false;
  }
  Serial.println("Task Dismissal Reset");
}

void dismissTask() {
  digitalWrite(ledPin, LOW);
  noTone(buzzerPin);
  displayDismissedMessage();
  Serial.println("Task Dismissed");
}

void displayDismissedMessage() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Task Dismissed.");
  Serial.println("Dismissed Message Displayed on LCD");
}

This code initializes the Task Reminder System, sets up the RTC, LCD, and I/O pins, and continuously checks the current time to trigger task alerts. The user can dismiss active tasks using the pushbutton.