Arduino can provide time related functions like in milli and micro seconds . However it can’t provide the real time (year, month, hour, minute and seconds). To obtain that information we will use different kinds of electronic components like RTC (Real Time Clock)and LCD display in order to get it in visual form.
Objectives #
- Know how we can use RTC ( Real Time Clock) in order to provide a precise time clock.
- To display that information on an LCD screen.
Component to Use #
- MPK kit A
- RTC ( Real Time Clock )
- LCD display ( with I2C module )
- Jumper wires
- Breadboard
- Microcontroller
Circuit Diagram #
NOTE: Refer to Project 16 for LCD display connection.
Figure: Components used to make connection on the board
Arduino codes #
// If you use the std C function : sprintf(my_array, “Temp: %4.2f”, my_temp), It will NOT CONVERT.
// So I abandoned this, since I don’t need to print the float to the LCD anyway.
// Convert normal decimal numbers to binary coded decimal
Code knowledge #
This program involves displaying the date, time, and temperature on an LCD screen, using the DS3231 Real-Time Clock (RTC) and an LCD display. It also prints these details to the Serial Monitor.
- These variables hold values for time (hours, minutes, seconds), date (day, date, month, year), and temperature (my_temp).
- my_array is used to store a message to display on the LCD.
This code block is part of the loop() function in an Arduino program, and it continuously reads the time, date, and temperature from an RTC (Real-Time Clock) module and displays them on an LCD and the Serial Monitor. Here’s a breakdown of each part:
- Check for Console Commands