Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to make the Arduino a clock. It should print time to the serial

ID: 3793528 • Letter: W

Question

Write a program to make the Arduino a clock. It should print time to the serial monitor every second (followed by a linefeed). The time should be in the format: hh: mm:ss (h = hours, m = minutes, s = seconds) You can print the time in 24 hr. format or 12 hr. format with the additional designations of AM and PM, your choice. Note you must print leading zeros if necessary, for example 3 minutes after 9 should be printed 09:03:00 Not 9:3:0 Assume your program begins executing at exactly 12 noon (12:00:00). Explain your code via comments in the code. Run this program manually to make sure it works, you need not run this program on an actual Arduino board. You may want to compile your program on the Arduino compiler to check for syntax errors (your option).

Explanation / Answer

#include #include // include the RTC library #include unsigned long milliseconds=0; //init the real time clock Rtc_Pcf8563 rtc; // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); lcd.print(" Arduino Clock!"); while(1500 - millis() > 0); pinMode(13, OUTPUT); } void loop() { lcd.setCursor(0, 0); lcd.print(rtc.formatTime()); delay(1000); milliseconds+=1000; if (milliseconds>= (1000*60*60*24*50)) milliseconds=0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote