Maintenance: Project Hub will be unavailable on Wednesday 25 (9AM to 6PM CET) while we deploy critical improvements
Led Matrix Clock using Arduino And RTC Module
Today iam going to show you how to make led matrix clock With Arduino & Rtc. this is a simple project does not require high knowledge
Components and supplies
1
Breadboard (generic)
1
Arduino Nano R3
2
Tactile Switch, Top Actuated
1
Female Header 8 Position 1 Row (0.1")
1
High Accuracy Pi RTC (DS3231)
1
Dot Pcb
1
Jumper wires (generic)
1
MAX7219 Led Matrix
Tools and machines
1
Desoldering Pump, Deluxe SOLDAPULLT®
1
PCB Holder, Soldering Iron
1
Solder Flux, Soldering
1
Solder Wire, Lead Free
1
Soldering iron (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Arduino Code
c9search
Upload The Code To Arduino Nano
1/*feel free to contact 2 * sreeramaj53@gmail.com 3 * www.youtube.com/ZenoModiff 4 * last updated - time 02:41 PM - date 06 july 2021 5 * Github Link :-- https://github.com/Zenomodiff/Max7219-Led-Matrix-Clock-With-DS3231-RTC-Module 6 */ 7 8#include "DS3231.h" 9#include "Adafruit_GFX.h" 10#include "Max72xxPanel.h" 11 12DS3231 rtc(SDA, SCL); 13 14const byte LDR_PIN = A2; 15const byte CS_PIN = A3; 16const byte H_DISPLAYS = 4; 17const byte V_DISPLAYS = 1; 18 19Max72xxPanel matrix = Max72xxPanel(CS_PIN, H_DISPLAYS, V_DISPLAYS); 20 21const byte WAIT = 30; 22const byte SPACER = 1; 23const byte FONT_WIDTH = 5 + SPACER; 24 25void setup() { 26 pinMode(LDR_PIN, INPUT_PULLUP); 27 Serial.begin(9600); 28 Serial.println(F(">> Arduino 32x8 LED Dot Matrix Clock!")); 29 Serial.println(F(">> Use <dd/mm/yyyy hh:mm:ss> format to set clock's date and hour!")); 30 rtc.begin(); 31 matrix.setPosition(0, 0, 0); 32 matrix.setPosition(1, 1, 0); 33 matrix.setPosition(2, 2, 0); 34 matrix.setPosition(3, 3, 0); 35 matrix.setRotation(0, 1); 36 matrix.setRotation(1, 1); 37 matrix.setRotation(2, 1); 38 matrix.setRotation(3, 1); 39} 40 41void loop() { 42 byte ledIntensity = ledIntensitySelect(analogRead(LDR_PIN)); 43 matrix.setIntensity(ledIntensity); 44 String output = outputStrClock(); 45 46 for ( int i = 0 ; i < FONT_WIDTH * output.length() + matrix.width() - 1 - SPACER; i++ ) { 47 matrix.fillScreen(LOW); 48 output = outputStrClock(); 49 int letter = i / FONT_WIDTH; 50 int x = (matrix.width() - 1) - i % FONT_WIDTH; 51 int y = (matrix.height() - 8) / 2; 52 while ( x + FONT_WIDTH - SPACER >= 0 && letter >= 0 ) { 53 if ( letter < output.length() ) { 54 matrix.drawChar(x, y, output[letter], HIGH, LOW, 1); 55 } 56 letter--; 57 x -= FONT_WIDTH; 58 } 59 matrix.write(); 60 delay(WAIT); 61 } 62 63 if (Serial.available() > 0) { 64 adjustClock(Serial.readString()); 65 } 66} 67 68void adjustClock(String data) { 69 byte _day = data.substring(0,2).toInt(); 70 byte _month = data.substring(3,5).toInt(); 71 int _year = data.substring(6,10).toInt(); 72 byte _hour = data.substring(11,13).toInt(); 73 byte _min = data.substring(14,16).toInt(); 74 byte _sec = data.substring(17,19).toInt(); 75 rtc.setTime(_hour, _min, _sec); 76 rtc.setDate(_day, _month, _year); 77 Serial.println(F(">> Datetime successfully set!")); 78} 79 80String outputStrClock() { 81 String _output; 82 _output = rtc.getDateStr(); 83 _output.concat(" "); 84 _output.concat(rtc.getTimeStr()); 85 _output.concat(" "); 86 _output.concat(rtc.getTemp()); 87 _output.concat((char)247); 88 _output.concat("C"); 89 return _output; 90} 91 92byte ledIntensitySelect(int light) { 93 byte _value = 0; 94 if (light >= 0 && light <= 127) { 95 _value = 15; 96 } else if (light >= 128 && light <= 319) { 97 _value = 10; 98 } else if (light >= 320 && light <= 512) { 99 _value = 5; 100 } 101 return _value; 102}; 103
Arduino Code
c9search
Upload The Code To Arduino Nano
1/*feel free to contact 2 * sreeramaj53@gmail.com 3 * www.youtube.com/ZenoModiff 4 * last updated - time 02:41 PM - date 06 july 2021 5 * Github Link :-- https://github.com/Zenomodiff/Max7219-Led-Matrix-Clock-With-DS3231-RTC-Module 6 */ 7 8#include "DS3231.h" 9#include "Adafruit_GFX.h" 10#include "Max72xxPanel.h" 11 12DS3231 rtc(SDA, SCL); 13 14const byte LDR_PIN = A2; 15const byte CS_PIN = A3; 16const byte H_DISPLAYS = 4; 17const byte V_DISPLAYS = 1; 18 19Max72xxPanel matrix = Max72xxPanel(CS_PIN, H_DISPLAYS, V_DISPLAYS); 20 21const byte WAIT = 30; 22const byte SPACER = 1; 23const byte FONT_WIDTH = 5 + SPACER; 24 25void setup() { 26 pinMode(LDR_PIN, INPUT_PULLUP); 27 Serial.begin(9600); 28 Serial.println(F(">> Arduino 32x8 LED Dot Matrix Clock!")); 29 Serial.println(F(">> Use <dd/mm/yyyy hh:mm:ss> format to set clock's date and hour!")); 30 rtc.begin(); 31 matrix.setPosition(0, 0, 0); 32 matrix.setPosition(1, 1, 0); 33 matrix.setPosition(2, 2, 0); 34 matrix.setPosition(3, 3, 0); 35 matrix.setRotation(0, 1); 36 matrix.setRotation(1, 1); 37 matrix.setRotation(2, 1); 38 matrix.setRotation(3, 1); 39} 40 41void loop() { 42 byte ledIntensity = ledIntensitySelect(analogRead(LDR_PIN)); 43 matrix.setIntensity(ledIntensity); 44 String output = outputStrClock(); 45 46 for ( int i = 0 ; i < FONT_WIDTH * output.length() + matrix.width() - 1 - SPACER; i++ ) { 47 matrix.fillScreen(LOW); 48 output = outputStrClock(); 49 int letter = i / FONT_WIDTH; 50 int x = (matrix.width() - 1) - i % FONT_WIDTH; 51 int y = (matrix.height() - 8) / 2; 52 while ( x + FONT_WIDTH - SPACER >= 0 && letter >= 0 ) { 53 if ( letter < output.length() ) { 54 matrix.drawChar(x, y, output[letter], HIGH, LOW, 1); 55 } 56 letter--; 57 x -= FONT_WIDTH; 58 } 59 matrix.write(); 60 delay(WAIT); 61 } 62 63 if (Serial.available() > 0) { 64 adjustClock(Serial.readString()); 65 } 66} 67 68void adjustClock(String data) { 69 byte _day = data.substring(0,2).toInt(); 70 byte _month = data.substring(3,5).toInt(); 71 int _year = data.substring(6,10).toInt(); 72 byte _hour = data.substring(11,13).toInt(); 73 byte _min = data.substring(14,16).toInt(); 74 byte _sec = data.substring(17,19).toInt(); 75 rtc.setTime(_hour, _min, _sec); 76 rtc.setDate(_day, _month, _year); 77 Serial.println(F(">> Datetime successfully set!")); 78} 79 80String outputStrClock() { 81 String _output; 82 _output = rtc.getDateStr(); 83 _output.concat(" "); 84 _output.concat(rtc.getTimeStr()); 85 _output.concat(" "); 86 _output.concat(rtc.getTemp()); 87 _output.concat((char)247); 88 _output.concat("C"); 89 return _output; 90} 91 92byte ledIntensitySelect(int light) { 93 byte _value = 0; 94 if (light >= 0 && light <= 127) { 95 _value = 15; 96 } else if (light >= 128 && light <= 319) { 97 _value = 10; 98 } else if (light >= 320 && light <= 512) { 99 _value = 5; 100 } 101 return _value; 102}; 103
Downloadable files
Schematics
Solder The PCB According To The Schematics
Schematics

Comments
Only logged in users can leave comments