Introduction: Real Time Clock - DS1302
Step 1: The Background
The 31 bytes of RAM is formatted as shown in the table below. Notice that the numeric positions have their own bits to fill. Specifically the 0-9 value of the 'ones' place have 4 bits, and the 0-9 value of the 'tens' place has 3 bits for the byte filled with the seconds value. These values are combined to create the entire byte.
This product, as well as the manufacturers datasheet, can be found at https://www.virtuabotix.com/product/virtuabotix-ds1302-real-time-clock-rtc-module-arduino-versalino/.
Step 2: Parts Selection
Step 3: Wiring Setup
Step 4: Code
The original code was provided from the Arduino website, http://playground.arduino.cc/Main/DS1302, which was contributed by user "Kodal". That code was translated into a full library, and expounded upon by Virtuabotix, LLC. The full description of the library, and its functions, can be found at https://www.virtuabotix.com/virtuabotix-ds1302-real-time-clock-module-pin-out-coding-guide/. Simply go to the 'Code' Section to find the link to the library.
This Instructable will address two examples that utilize the library.
*NOTE: The library does NOT use the full functionality of the DS1302 chip, it does use the most common functions that are requested.
Step 5: Code (Example 1)
This example simply allows for printing out the data, and allows for direct user access to the individual elements. Thus printing each element at a time. This, of course, can be printed out in any format, this one just seemed the easiest. As always, this example can be turned into a function..
This example is included in the library that can be found at: The full description of the library, and its functions, can be found at https://www.virtuabotix.com/virtuabotix-ds1302-real-time-clock-module-pin-out-coding-guide/. Simply go to the 'Code' Section to find the link to the library. Once the library is imported, you can find the example in File->Examples.
Step 6: Code (Example 2)
This example utilizes two Superbright LEDs to indicate whether your RTC is actively updating. This is illustrated by wither a Green LED, for good; or a RED LED for not updating. This is simply accomplished by storing a read of the seconds and checking that against the current RTC time. If it has updated you get a Green LED illuminated, if not you get the Red LED.
This example is included in the library that can be found at: The full description of the library, and its functions, can be found at https://www.virtuabotix.com/virtuabotix-ds1302-real-time-clock-module-pin-out-coding-guide/. Simply go to the 'Code' Section to find the link to the library. Once the library is imported, you can find the example in File->Examples.
Step 7: Conclusion
Step 8: Demo
This video has a Demo of both Examples:
As before the examples and the library can be found at https://www.virtuabotix.com/virtuabotix-ds1302-real-time-clock-module-pin-out-coding-guide/....
Thanks for viewing my first Instructable...