wrightmac
Published

Dualie 8x8 Scrolling RTC Clock

A couple of 8x8 matrices, RTC, an Arduino, and a cardboard box; along with a couple of hours free time and a quick clock can be yours.

BeginnerWork in progress1 hour933
Dualie 8x8 Scrolling RTC Clock

Things used in this project

Hardware components

ELEGOO UNO R3 Board ATmega328P ATMEGA16U2 with USB Cable
ELEGOO UNO R3 Board ATmega328P ATMEGA16U2 with USB Cable
×1
Keyestudio 8x8 LED Matrix, HT16K33, I2C
×2
DS3231MPMB1 Peripheral Module
Maxim Integrated DS3231MPMB1 Peripheral Module
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

SimpleScrolllingClock_code

Arduino
This is version 0.2 of the code used in this project.
/*************************************************** 
  Project:    Dualie 8x8 LED matrix simple clock
  Author:     Peter Hein
  Hardware:   Arduino UNO R3, generic - HK16K33 keystudio - DS3231 RTC
              all devices are I2C, Uno Pin 5 = SCL and Pin 4 = SDA
  Revision:   0.2
  Date:       28 August 2019
  License:    BSD

  version history
      0.1 - first run
      0.2 - remove seconds, cut down on scroll length, and cleanup.
            post to github
  
  ---- Adafruit License -----
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED Matrix backpacks 
  ----> http://www.adafruit.com/products/872
  ----> http://www.adafruit.com/products/871
  ----> http://www.adafruit.com/products/870

  These displays use I2C to communicate, 2 pins are required to 
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// Libraries needed 
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

// variables
int Hour = 0;
int Minute = 0;
int Second = 0;
int ap;
char t[8];

// setup devices
Adafruit_8x8matrix matrix1 = Adafruit_8x8matrix();
Adafruit_8x8matrix matrix2 = Adafruit_8x8matrix();
RTC_DS3231 Clock;

void setup() {
  // Bring up serial for debugging. 
  Serial.begin(9600);
  Serial.println("8x8 LED Matrix Test");

  // Start the clock
  Clock.begin();
  
  // Pass the addresses of the matricies
  matrix1.begin(0x72);  
  matrix2.begin(0x70);
}

void loop() {
  
  // This line sets the RTC with an explicit date & time, for example to set
  // July 29, 2019 at 13:08:00 you would call:
  // Clock.adjust(DateTime(2019, 8, 28, 20, 37, 0));

  // At the tone the time will be. . . 
  DateTime now = Clock.now();
  Second = now.second(); 
  Minute = now.minute();
  Hour = now.hour();
  // Set time to 12 hour clock
   if (now.hour() >= 13)
  {
    Hour = (now.hour() - 12);
  }
  if (Hour == 00)
  { 
    Hour =12;
  }

  // Setting up my time string to print to the matrix
  // sprintf(t, "  %02d:%02d:%02d", Hour, Minute, Second);
  sprintf(t, "  %02d:%02d ", Hour, Minute);  

  // A little debugging
  Serial.println("At the tone the time will be");   
  Serial.print(Hour, DEC);
  Serial.print(":");
  Serial.print(Minute, DEC);
  Serial.print(":");
  Serial.println(Second, DEC);

  // Clear the screens
  matrix1.clear();
  matrix2.clear();

  matrix1.setTextSize(1);
  matrix1.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  matrix1.setTextColor(LED_ON);
  matrix1.setRotation(1);
  matrix1.setBrightness(7);
  
  matrix2.setTextSize(1);
  matrix2.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  matrix2.setTextColor(LED_ON);
  matrix2.setRotation(1);
  matrix2.setBrightness(7);

  // The text to scroll across both screens
  Scroll(t);
}

void Scroll(char* text)
{
  // scrolling the text across the screen from right to left
  for (int8_t x=0; x>=-22; x--) {
    matrix1.clear();
    matrix2.clear();
    matrix1.setCursor(x,0);
    matrix2.setCursor(x-8,0);
    matrix1.print(text);
    matrix2.print(text);
    matrix1.writeDisplay();
    matrix2.writeDisplay();
    delay(100);
  }
}

SimpleScrollingClock

Credits

wrightmac

wrightmac

16 projects • 22 followers
Network geek by day, apprentice hardware hacker by night, curious-tinkerer always, and Apple Fanboy since 1984!
Thanks to Limor Fried/Ladyada for Adafruit Industries.

Comments