Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Real-Time Clock Display with Adafruit LED Backpack

View and Edit Project In Cirkit DesignerImage of Arduino-Based Real-Time Clock Display with Adafruit LED Backpack

Circuit Documentation

Summary

This circuit is designed to read the current time from a DS1307 Real-Time Clock (RTC) and display it on an Adafruit 0.56 inch 7-segment LED Backpack. The Arduino UNO microcontroller is used to manage the I2C communication between the RTC and the LED display. The time is updated on the LED display every second, providing a real-time clock functionality.


Component List

Arduino UNO

DS1307 RTC

Adafruit 0.56 inch 7-segment LED Backpack


Wiring Details

Arduino UNO


DS1307 RTC


Adafruit 0.56 inch 7-segment LED Backpack


Documented Code

/*
 * Arduino Sketch for reading time from a DS1307 RTC and displaying it on an
 * Adafruit LED Backpack. The circuit uses I2C communication to interface with
 * both the RTC and the LED display. The time is read from the RTC and updated
 * on the LED display every second.
 */

#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>

// Create RTC and LED display objects
RTC_DS1307 rtc;
Adafruit_7segment display = Adafruit_7segment();

void setup() {
  // Initialize I2C communication
  Wire.begin();

  // Initialize RTC
  if (!rtc.begin()) {
    // If RTC is not found, halt the program
    while (1);
  }

  // Check if the RTC is running
  if (!rtc.isrunning()) {
    // Set the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }

  // Initialize the LED display
  display.begin(0x70); // Default I2C address for the backpack
}

void loop() {
  DateTime now = rtc.now();

  int h = now.hour();
  int m = now.minute();

  // Convert to 12-hour format
  int h12 = h % 12;
  if (h12 == 0) h12 = 12;

  display.clear();

  // Hours
  if (h12 >= 10) {
    display.writeDigitNum(0, h12 / 10);  // tens of hour
  }
  display.writeDigitNum(1, h12 % 10);     // ones of hour

  // Colon on
  display.drawColon(true);

  // Minutes
  display.writeDigitNum(3, m / 10);       // tens of minute
  display.writeDigitNum(4, m % 10);       // ones of minute

  display.writeDisplay();
  delay(1000);
}

This documentation provides a comprehensive overview of the circuit, detailing the components used, their connections, and the code that drives the functionality of the system.