: Push date/time values from the Arduino into the DS1302 registers.

The DS1302 uses a 3-wire synchronous serial interface to communicate with the Arduino. Unlike I2C modules (like the DS3231) which require specific hardware pins (A4 and A5 on the Arduino Uno), the DS1302 can be connected to on your Arduino board. Pinout Configuration DS1302 Pin Description Arduino Pin (Example) VCC Main Power Supply (5V or 3.3V) GND CLK / SCLK Serial Clock Digital Pin 6 DAT / IO Serial Data Digital Pin 7 RST / CE Reset / Chip Enable Digital Pin 8 Installing the VirtuabotixRTC Library

#include <virtuabotixRTC.h>

However, it's important to note that the DS1302's quartz crystal is external, which can sometimes lead to time drift issues (the clock running fast or slow). For projects requiring extreme precision, a higher-end chip like the DS3231, which has a built-in temperature-compensated crystal, is often recommended. The DS3231 is much more accurate compared to the DS1307 and DS1302.

The DS1302 can store time in 12-hour format with AM/PM flags. Use myRTC.hourmode which returns 12-hour value, and myRTC.ampm (1 = PM, 0 = AM). You set the mode during setDS1302Time() .

void setup() rtc.setDateTime(2022, 7, 25, 10, 30, 0);