// LCD2004 and Pi Pico!

/*-data-type------size---------description-----
  boolean        (8 bit)   -  [true/false]
  byte           (8 bit)   -  [0-255] unsigned number
  char           (8 bit)   -  [-128 to 127] signed number
  unsigned char  (8 bit)   -  [-128 to 127] signed number
  word           (16 bit)  -  [0-65535] unsigned number
  unsigned int   (16 bit)  -  [0-65535] unsigned number
  int            (16 bit)  -  [-32768 to 32767] signed number
  unsigned long  (32 bit)  -  [0-4,294,967,295] unsigned number usually for millis
  long           (32 bit)  -  [-2,147,483,648 to 2,147,483,647] signed number
  float          (32 bit)  -  [-3.4028235E38 to 3.4028235E38] signed number
  uint8_t        (8 bit)   -  [0-255] unsigned number
  int8_t         (8 bit)   -  [-127 - 127] signed number
  uint16_t       (16 bit)  -  [0-65,535] unsigned number
  int16_t        (16 bit)  -  [-32,768 - 32,767] signed number
  uint32_t       (32 bit)  -  [0-4,294,967,295] unsigned number
  int32_t        (32 bit)  -  [-2,147,483,648 - 2,147,483,647] signed number
  uint64_t       (64 bit)  -  [0-18,446,744,073,709,551,615] unsigned number
  int64_t        (64 bit)  -  [−9,223,372,036,854,775,808 - 9,223,372,036,854,775,807] signed number
  --------------------------------------------
  camelCase                -  anything that changes
  snake_case               -  variable's that are exclusive in a function
  Snake_Case               -  CLASS/struct exclusave varables/functions
  iNVERTEDcAMELcASE        -  outside code that is being accessed [database]
  SNake_CAse               -  duplicate varables inside the case function [frequently used in library names]
  ALL_CAPS                 -  const varable names or defines
  -------------by-jediRick--------------------
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int32_t hour = 24, minute = 59, second = 50, day = 22, month = 7, year = 2022;

void setup() {
  Wire.setSDA(8);
  Wire.setSCL(9);
  Wire.begin();
  lcd.init();
  lcd.backlight();
  lcd.begin(0, 2);
  lcd.setCursor(3, 1);
  lcd.print("> Pico Clock <");
  delay(2000);
  lcd.clear();
}

void loop() {
  int32_t current_time = (hour * 3600) + (minute * 60) + second; //trying to calculate the time
  int32_t time_seconds = current_time + (millis() / 1000);
  if (time_seconds >= 0) {
    int32_t time_hour = time_seconds / 3600 - 1;
    int32_t time_minute = ((time_seconds / 60) % 60);
    int32_t time_sec = time_seconds % 60;
    if (time_hour >= 24) { //reset time and day once we pass 24 hours
      day = day + 1;
      hour = 0;
    }
    lcd.setCursor(6, 1);  // echo time with leading zero
    if (time_hour < 10) {
      lcd.print("0");
    }
    lcd.print(time_hour);
    lcd.print(":");
    if (time_minute < 10) {
      lcd.print("0");
    }
    lcd.print(time_minute);
    lcd.print(":");
    if (time_sec < 10) {
      lcd.print("0");
    }
    lcd.print(time_sec);
    lcd.setCursor(5, 2);
    if (day < 10) {
      lcd.print("0");
    }
    lcd.print(day);
    lcd.print("/");
    if (month < 10) {
      lcd.print("0");
    }
    lcd.print(month);
    lcd.print("/");
    lcd.print(year);
  }
  delay(500);
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
lcd:GND
lcd:VCC
lcd:SDA
lcd:SCL