Easy to Understand 60 Second Series - Real Time Clock manipulated by buttons

  Рет қаралды 40

Waiduino

Waiduino

Күн бұрын

Пікірлер: 4
@kumonuser2439
@kumonuser2439 Жыл бұрын
Ehhh mazing 🎉
@Waiduino
@Waiduino Жыл бұрын
Epoch time convertor: www.epochconverter.com/ #include #include #define TIME_HEADER "T" // Header tag for serial time sync message #define TIME_REQUEST 7 // ASCII bell character requests a time sync message const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; int buttonApin = 9; int buttonBpin = 8; int r; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { lcd.begin(16, 2); Serial.begin(9600); pinMode(buttonApin, INPUT_PULLUP); pinMode(buttonBpin, INPUT_PULLUP); while (!Serial) ; // Needed for Leonardo only pinMode(13, OUTPUT); setSyncProvider(requestSync); // Set function to call when sync required Serial.println("Waiting for sync message"); lcd.print("Loading....."); } void loop() { if (Serial.available()) { processSyncMessage(); } if (timeStatus() != timeNotSet) { digitalClockDisplay(); } if (timeStatus() == timeSet) { digitalWrite(13, HIGH); // LED on if synced } else { digitalWrite(13, LOW); // LED off if needs refresh } // Button handling if (digitalRead(buttonApin) == LOW) { adjustTime(3600); // Add 3600 seconds (1 hour) to the time delay(200); // Debounce delay } if (digitalRead(buttonBpin) == LOW) { adjustTime(60); // Add 60 seconds (1 minute) to the time delay(200); // Debounce delay } delay(1000); lcd.setCursor(0, 0); } void digitalClockDisplay() { lcd.print("Time "); if (hour() == 12 || hour() == 0 || hour() == 24) { lcd.print("12"); } else if (hour() > 9) { r = hour() % 12; if (r < 10) { lcd.print("0"); } lcd.print(r); Serial.print(hour() % 12); } else { lcd.print("0"); lcd.print(hour()); Serial.print(hour()); } // Display AM or PM printDigits(minute()); printDigits(second()); if (hour() < 12) { lcd.print(" AM"); } else { lcd.print(" PM"); } lcd.setCursor(0, 1); lcd.print("Date "); lcd.print(month()); lcd.print("/"); lcd.print(day()); lcd.print("/"); lcd.print(year()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); } void printDigits(int digits) { lcd.print(":"); if (digits < 10) lcd.print('0'); lcd.print(digits); } void processSyncMessage() { unsigned long pctime; const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 if (Serial.find(TIME_HEADER)) { pctime = Serial.parseInt(); if (pctime >= DEFAULT_TIME) { setTime(pctime); // Sync Arduino clock to the time received on the serial port } } } time_t requestSync() { Serial.write(TIME_REQUEST); return 0; // The time will be sent later in response to a serial message }
@manjuyadav-ws4xd
@manjuyadav-ws4xd 11 ай бұрын
You deserve clout😢
@Waiduino
@Waiduino 11 ай бұрын
Yea I’m really hoping my channel will start growing a ton! Overall I just enjoy people watching my content to see the things I make and possibly make it themselves. But in any case, I am so thankful for all of my subscribers, especially you for commenting and your compliment. Thank you
Best Delivery Driver Videos of the Decade
10:28
Daily Dose Of Internet
Рет қаралды 2,3 МЛН
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 8 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,2 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 112 МЛН
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 7 МЛН
The smartest dog in the world | 60 Minutes Archive
12:59
60 Minutes
Рет қаралды 17 МЛН
Turning my iPhone into a Terrible Windows Phone
18:36
MetraByte
Рет қаралды 74 М.
How to make a simple led traffic light circuit
3:56
Project AA
Рет қаралды 16 М.
Palestine Must Be Free | Stand-up Comedy by Daniel Fernandes
15:07
Daniel Fernandes
Рет қаралды 353 М.
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 2 МЛН
I Saved an Electron Microscope from the Trash
34:54
ProjectsInFlight
Рет қаралды 591 М.
Truly innovative FPS games
16:57
Riloe
Рет қаралды 410 М.
8 SIMPLE INVENTIONS
11:06
Inventor 101
Рет қаралды 23 МЛН
It’s time to move on from Agile Software Development (It's not working)
11:07
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 8 МЛН