ARDUINO TIMER / POMODORO TECHNIQUE UNDER 8 MINUTES !!

 



- PROCEDURE -

STEP 1 -: 
 
Download the Arduino app on your laptop/desktop. Here is the link for the same,
                                                 -  DOWNLOAD LINK -

STEP 2 -: 

Open the Arduino app and click on the file left above, after that click on new. 





STEP 3 -: 

Copy the whole code and paste it into it. 

- CODE -

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

LiquidCrystal_I2C lcd(0x27, 16, 2);  // I2C address 0x27, 16 columns and 2 rows

const unsigned long greetingInterval = 5000;        // Display greeting for 5 seconds
const unsigned long studyMessageInterval = 5000;     // Display study message for 5 seconds
const unsigned long startingMessageInterval = 5000;  // Display starting message for 5 seconds
const unsigned long countdownInterval = 1000;        // Update countdown every 1 second
const unsigned long studyTime = 26UL * 60UL * 1000UL;  // 26 minutes in milliseconds
const unsigned long breakTime = 7UL * 60UL * 1000UL;        // 7 minutes break time in milliseconds

unsigned long lastDisplayTime = 0;  // Variable to store the last display time
unsigned long countdownStartTime = 0;  // Variable to store countdown start time
int currentPhase = 0;  // Variable to track the current phase

void setup() {
  lcd.begin(16, 2);  // initialize the lcd
  lcd.backlight();   // turn on the backlight

  // Display greeting message initially
  lcd.setCursor(0, 0);
  lcd.print("(:HELLO GUYS:) "); // You can make changes here inside " " 
  delay(greetingInterval);  // Display greeting for the specified interval
}

void loop() {
  // Get the current time
  unsigned long currentTime = millis();

  // Check the current phase and switch the display accordingly
  switch (currentPhase) {
    case 0:
      displayStudyMessage(currentTime);
      break;
    case 1:
      displayStartingMessage(currentTime);
      break;
    case 2:
      displayCountdown(currentTime);
      break;
    case 3:
      displayBreakMessage(currentTime);
      break;
  }

  // You can add additional functionality here if needed
}

void displayStudyMessage(unsigned long currentTime) {
  // Check if it's time to switch to the study message
  if (currentTime - lastDisplayTime >= studyMessageInterval) {
    // Switch the display to study message
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("LIKE , SHARE !"); // You can make changes here inside " " 
    lcd.setCursor(0, 1);
    lcd.print("SUBSCRIBE!!"); // You can make changes here inside " " 
    
    // Update phase and reset last display time
    currentPhase++;
    lastDisplayTime = currentTime;
  }
}

void displayStartingMessage(unsigned long currentTime) {
  // Check if it's time to switch to the starting message
  if (currentTime - lastDisplayTime >= startingMessageInterval) {
    // Switch the display to starting message
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Starting AURABOT"); // You can make changes here inside " " 
    lcd.setCursor(0, 1);
    lcd.print("By AKS"); // You can make changes here inside " " 
    
    // Update phase and reset last display time
    currentPhase++;
    lastDisplayTime = currentTime;
    
    // Set countdown start time when starting AURABOT
    countdownStartTime = currentTime;
  }
}

void displayCountdown(unsigned long currentTime) {
  // Check if it's time to switch to the countdown
  if (currentTime - lastDisplayTime >= countdownInterval) {
    // Display countdown on LCD
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Countdown: ");
    
    // Calculate remaining time in milliseconds
    unsigned long elapsedTime = currentTime - countdownStartTime;
    unsigned long remainingTime = studyTime - elapsedTime;

    // Convert remaining time to minutes and seconds
    int minutes = remainingTime / 60000;
    int seconds = (remainingTime % 60000) / 1000;

    // Display countdown in the specified format
    lcd.print(minutes);
    lcd.print(":");
    if (seconds < 10) {
      lcd.print("0");  // Add leading zero for single-digit seconds
    }
    lcd.print(seconds);

    // Update countdown every 1 second
    lastDisplayTime = currentTime;

    // Check if the countdown has reached zero
    if (remainingTime <= 0) {
      // Reset the countdown start time and move to the break message phase
      countdownStartTime = currentTime;
      currentPhase++;
    }
  }
}

void displayBreakMessage(unsigned long currentTime) {
  // Check if it's time to switch to the break message
  if (currentTime - lastDisplayTime >= countdownInterval) {
    // Display break message on LCD
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Take a Break for"); // You can make changes here inside " " 
    lcd.setCursor(0, 1);
    lcd.print("7 Minutes"); // You can make changes here inside " " 
    
    // Update phase and reset last display time
    currentPhase++;
    lastDisplayTime = currentTime;

    // Set countdown start time for the break
    countdownStartTime = currentTime;
  }
}

 
STEP 4 -: 

Download This Library -: 

LCD library -: Download

 After opening the above-given link, you have to click on ' CODE ' then select 'DOWNLOAD ZIP' and save it in any folder you want. 



STEP 5 -: 

Now open the Arduino app and click on " SKETCH > INCLUDE LIBRARY > ADD . ZIP LIBRARY ". Then open the folder where you saved the LCD library and click on that file. 



STEP 6 -: 

Check if both the libraries, i.e #include <Wire.h> and  #include <LiquidCrystal_I2C.h> are displaying colourful, in such way -: 



STEP 7 -: 

If the Wire library is displayed in a normal text, then you have to download the library by yourself but in most of the cases, the Wire library is pre-downloaded. 
To download it follow the steps -: 

SKETCH > INCLUDE LIBRARY >  MANAGE LIBRARIES > THEN SEARCH FOR WIRE AND INSTALL THE FIRST ONE. 


AT LAST, SAVE THE CODE USING " CTRL + S ". 

YOUR PROJECT IS READY !!!
- AKS (Assured Krafted System) 

Comments

Popular posts from this blog

HOW TO BUILD A CALCULATOR USING C LANGUAGE???