stevie135s
Created November 12, 2022 © GPL3+

Big Clock Matrix

A big clock project using an 8x32 WS2812b Matrix, a DS1302 RTC and an Arduino ESP32 WROOM

IntermediateWork in progress158
Big Clock Matrix

Things used in this project

Hardware components

Arduino ESP32 WROOM
×1
8x32 WS2812b Matrix
×1
DS1302 RTC
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Diffuser

3D print files

Rear support

3D print files

Schematics

Big Clock

Wiring used in the project

Code

Big Clock ino

Arduino
Upload to the ESP32 WROOM using the Arduino IDE
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <Ds1302.h>


#define PIN 25 // This is the led signal pin

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
  NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);
  
Ds1302 rtc (14,26,27); //(PIN_ENA, PIN_CLK, PIN_DAT)

byte last_second = 60;
byte h1,h2;
bool flash = 0; // Flashing Dots

const uint8_t hms [][2] = { // Array to separate the two digits hh mm ss
  {0,0},{0,1},{0,2},{0,3},{0,4},{0,5},{0,6},{0,7},{0,8},{0,9},
  {1,0},{1,1},{1,2},{1,3},{1,4},{1,5},{1,6},{1,7},{1,8},{1,9},
  {2,0},{2,1},{2,2},{2,3},{2,4},{2,5},{2,6},{2,7},{2,8},{2,9},
  {3,0},{3,1},{3,2},{3,3},{3,4},{3,5},{3,6},{3,7},{3,8},{3,9},
  {4,0},{4,1},{4,2},{4,3},{4,4},{4,5},{4,6},{4,7},{4,8},{4,9},
  {5,0},{5,1},{5,2},{5,3},{5,4},{5,5},{5,6},{5,7},{5,8},{5,9}
  };

const uint16_t colors[] = {
  matrix.Color(204, 0, 204), matrix.Color(204, 204, 0), matrix.Color(0, 255, 255),
  matrix.Color(255, 10, 127), matrix.Color(127, 0, 255), matrix.Color(0, 255, 0),
  matrix.Color(255, 99, 255), matrix.Color(204,177,0), matrix.Color(0,0,244) };  // Colour presets

static const uint8_t PROGMEM
num_bmp [] [7] = { // Bitmap Characters 0 - 9
  { // 0
    B01110,
    B10001,
    B10001,
    B10001,
    B10001,
    B10001,
    B01110,
  },
  { //1
    B00100,
    B01100,
    B00100,
    B00100,
    B00100,
    B00100,
    B01110,
  },
  { //2
    B01110,
    B10001,
    B00001,
    B00010,
    B00100,
    B01000,
    B11111,
  },
  { //3
    B01110,
    B10001,
    B00001,
    B00110,
    B00001,
    B10001,
    B01110,
  },
  { //4
    B10000,
    B10000,
    B10100,
    B10100,
    B01111,
    B00100,
    B00100,
  },
  { //5
    B11110,
    B10000,
    B10000,
    B01110,
    B00001,
    B10001,
    B01110,
  },
  { //6
    B01110,
    B10001,
    B10000,
    B11110,
    B10001,
    B10001,
    B01110,
  },
  { //7
    B11111,
    B00001,
    B00010,
    B00010,
    B00100,
    B00100,
    B01000,
  },
  { //8
    B01110,
    B10001,
    B10001,
    B01110,
    B10001,
    B10001,
    B01110,
  },
  { //9
    B01110,
    B10001,
    B10001,
    B01111,
    B00001,
    B10001,
    B01110,
  }
  
};


void setup() {
  rtc.init();
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(20);
  matrix.setTextColor(colors[0]);
}


void loop() {

  Ds1302::DateTime now;
  rtc.getDateTime (&now);
  if (last_second != now.second) {
    last_second = now.second;
    matrix.fillScreen(0);
    if (flash) {
   matrix.drawPixel(10,2,colors[1]);
   matrix.drawPixel(10,5,colors[1]);
   matrix.drawPixel(21,2,colors[1]);
   matrix.drawPixel(21,5,colors[1]);
    }
    flash = !flash;
    h1 = hms[now.hour] [0];
    h2 = hms[now.hour] [1];
    matrix.drawBitmap(-3,1,num_bmp[h1],8,7,colors[2]);
    matrix.drawBitmap(2,1,num_bmp[h2],8,7,colors[2]);
    h1 = hms[now.minute] [0];
    h2 = hms[now.minute] [1];
    matrix.drawBitmap(8,1,num_bmp[h1],8,7,colors[2]);
    matrix.drawBitmap(13,1,num_bmp[h2],8,7,colors[2]);   
    h1 = hms[now.second] [0];
    h2 = hms[now.second] [1];
    matrix.drawBitmap(19,1,num_bmp[h1],8,7,colors[2]);
    matrix.drawBitmap(24,1,num_bmp[h2],8,7,colors[2]); 

    }
     matrix.show();   
  }





  

Credits

stevie135s
28 projects • 12 followers
I've been interested in microprocessors for a long time.
Contact

Comments

Please log in or sign up to comment.