Components and supplies
2
4K7 Resistor
1
MAXX7219 Display unit
1
Stripboard 37*24
1
Arduino Nano R3
1
0.1 inch 5 way socket
2
0.1 inch 15 way socket
1
0.1 inch 4 way pin strip
1
0.1 inch 6 way socket
1
Ds3231 clock module
Apps and platforms
1
Arduino IDE
Project description
Code
4*Maxx7219 clock
c_cpp
1/* 2 * 3 * Read time from Ds3231 real time clock and display on 4*Maxx7219 display 4 * December 2021 5 * 6 * 7*/ 8 9//for the clock 10#include <DS3231.h> 11#include <Wire.h> 12DS3231 Clock; 13bool h12; 14bool PM; 15 16 17// For the display 18#include "LedControl.h" 19/* 20 ***** Pin numbers for LedControl ***** 21 pin 11 is connected to the DataIn 22 pin 13 is connected to the CLK 23 pin 10 is connected to LOAD / CS 24 We have 4* MAX72XX. 25*/ 26const int total_displays=4; 27LedControl lc = LedControl(11, 13, 10, total_displays); 28 29// Character table for clock numbers 30/* 31int Matrix[][X] = { {1,2,3,4,...,X},// initializers for row indexed by 0 32 {3,4,5,6,...,X},// initializers for row indexed by 1 33 {1,9,2,8,...,X},// initializers for row indexed by 2 34 {9,8,7,6,...,X} }; 35*/ 36 37 byte my_array [11][8]={ 38 {B01110000, //0 39 B10001000, 40 B10011000, 41 B10101000, 42 B11001000, 43 B10001000, 44 B01110000,B00000000}, 45 //6, 46 47 {B01000000, //1 48 B11000000, 49 B01000000, 50 B01000000, 51 B01000000, 52 B01000000, 53 B11100000,B00000000}, 54 //4, 55 56 {B01110000, //2 57 B10001000, 58 B00001000, 59 B00010000, 60 B00100000, 61 B01000000, 62 B11111000,B00000000}, 63 //6, 64 65 {B11111000, //3 66 B00010000, 67 B00100000, 68 B00010000, 69 B00001000, 70 B10001000, 71 B01110000,B00000000}, 72 //6, 73 74 {B00010000, //4 75 B00110000, 76 B01010000, 77 B10010000, 78 B11111000, 79 B00010000, 80 B00010000,B00000000}, 81 //6, 82 83 {B11111000, //5 84 B10000000, 85 B11110000, 86 B00001000, 87 B00001000, 88 B10001000, 89 B01110000,B00000000}, 90 //6, 91 92 {B00110000, //6 93 B01000000, 94 B10000000, 95 B11110000, 96 B10001000, 97 B10001000, 98 B01110000,B00000000}, 99 //6, 100 101 {B11111000, //7 102 B10001000, 103 B00001000, 104 B00010000, 105 B00100000, 106 B00100000, 107 B00100000,B00000000}, 108 //6, 109 110 {B01110000, //8 111 B10001000, 112 B10001000, 113 B01110000, 114 B10001000, 115 B10001000, 116 B01110000,B00000000}, 117 //6, 118 119 {B01110000, //9 120 B10001000, 121 B10001000, 122 B01111000, 123 B00001000, 124 B00010000, 125 B01100000,B00000000}, 126 //6, 127 128 {B00000000, //blank 129 B00000000, 130 B00000000, 131 B00000000, 132 B00000000, 133 B00000000, 134 B0000000,B00000000} 135}; 136 137void setup() 138{ 139 // Wakeup call for MAX72XX 140 lc.shutdown(0, false); 141 lc.shutdown(1, false); 142 lc.shutdown(2, false); 143 lc.shutdown(3, false); 144 145 // Set the brightness to a medium values 146 lc.setIntensity(0, 2); 147 lc.setIntensity(1, 2); 148 lc.setIntensity(2, 2); 149 lc.setIntensity(3, 2); 150 151 // Clear display 152 lc.clearDisplay(0); 153 lc.clearDisplay(1); 154 lc.clearDisplay(2); 155 lc.clearDisplay(3); 156 157 // Start the I2C interface 158 Wire.begin(); 159 160} 161 162void loop() 163{ 164 165int i=0; 166int j=0; 167 168const int blank_space=10;//position of blank space in my_array[][] 169 170static int hours=0; 171static int minutes=0; 172static int hours_tens=0; 173static int hours_units=0; 174static int minutes_tens=0; 175static int minutes_units=0; 176static bool decimal_point_on =true; 177 178minutes=Clock.getMinute(); 179hours=Clock.getHour(h12, PM); 180 181hours_tens=(hours/10); 182hours_units=(hours%10); 183minutes_tens=(minutes/10); 184minutes_units=(minutes%10); 185 186//blank leading zero's 187if (hours<10){hours_tens=blank_space;} 188 189//Function format:display_write(row,data,display_number,total_displays) 190//row = an individual line on an individual display (1=top line 8=bottom line) 191//data = 8 bits - bit=1 led on, bit=0 led off 192//display_number = rightmost display is 0 count upwards to the display you wish to address 193//total_displays = the total number of displays you have chained together 194 195//write data to displays 196for (i=0;i<10;i++){ 197for(j=0;j<8;j++){display_write(j+1,my_array[minutes_units][j],0,total_displays);} 198 199for(j=0;j<8;j++){display_write(j+1,my_array[minutes_tens][j],1,total_displays);} 200 201 202for(j=0;j<8;j++){switch(j){case 3:display_write(j+1,decimal_point(my_array[hours_units][j],decimal_point_on),2,total_displays);break; 203 case 4:display_write(j+1,decimal_point(my_array[hours_units][j],decimal_point_on),2,total_displays);break; 204 default:display_write(j+1,my_array[hours_units][j],2,total_displays);break;} } 205 206for(j=0;j<8;j++){display_write(j+1,my_array[hours_tens][j],3,total_displays);} 207 208} 209 210 211 212delay(200); 213 214decimal_point_on=!decimal_point_on; 215 216} 217 218// My_functions 219 220//function to add or remove decimal point for particular display segment 221byte decimal_point(byte x,bool y){if (y){x|=0b00000010;}else{x&=0b11111101;}return x;} 222 223 224// Function to transfer a row of data to specific display 225void display_write(int row, int value, int display_number, int total_displays) { 226 227int i=0; 228 229//transfer data to display_number only 230for (i=total_displays;i>=0;i--){if (i==display_number){lc.setRow(i,row,value);} } //void setRow(int addr, int row, byte value); 231 232} 233 234// End of program 235
4*Maxx7219 clock
c_cpp
1/* 2 * 3 * Read time from Ds3231 real time clock and display on 4*Maxx7219 display 4 * December 2021 5 * 6 * 7*/ 8 9//for the clock 10#include <DS3231.h> 11#include <Wire.h> 12DS3231 Clock; 13bool h12; 14bool PM; 15 16 17// For the display 18#include "LedControl.h" 19/* 20 ***** Pin numbers for LedControl ***** 21 pin 11 is connected to the DataIn 22 pin 13 is connected to the CLK 23 pin 10 is connected to LOAD / CS 24 We have 4* MAX72XX. 25*/ 26const int total_displays=4; 27LedControl lc = LedControl(11, 13, 10, total_displays); 28 29// Character table for clock numbers 30/* 31int Matrix[][X] = { {1,2,3,4,...,X},// initializers for row indexed by 0 32 {3,4,5,6,...,X},// initializers for row indexed by 1 33 {1,9,2,8,...,X},// initializers for row indexed by 2 34 {9,8,7,6,...,X} }; 35*/ 36 37 byte my_array [11][8]={ 38 {B01110000, //0 39 B10001000, 40 B10011000, 41 B10101000, 42 B11001000, 43 B10001000, 44 B01110000,B00000000}, 45 //6, 46 47 {B01000000, //1 48 B11000000, 49 B01000000, 50 B01000000, 51 B01000000, 52 B01000000, 53 B11100000,B00000000}, 54 //4, 55 56 {B01110000, //2 57 B10001000, 58 B00001000, 59 B00010000, 60 B00100000, 61 B01000000, 62 B11111000,B00000000}, 63 //6, 64 65 {B11111000, //3 66 B00010000, 67 B00100000, 68 B00010000, 69 B00001000, 70 B10001000, 71 B01110000,B00000000}, 72 //6, 73 74 {B00010000, //4 75 B00110000, 76 B01010000, 77 B10010000, 78 B11111000, 79 B00010000, 80 B00010000,B00000000}, 81 //6, 82 83 {B11111000, //5 84 B10000000, 85 B11110000, 86 B00001000, 87 B00001000, 88 B10001000, 89 B01110000,B00000000}, 90 //6, 91 92 {B00110000, //6 93 B01000000, 94 B10000000, 95 B11110000, 96 B10001000, 97 B10001000, 98 B01110000,B00000000}, 99 //6, 100 101 {B11111000, //7 102 B10001000, 103 B00001000, 104 B00010000, 105 B00100000, 106 B00100000, 107 B00100000,B00000000}, 108 //6, 109 110 {B01110000, //8 111 B10001000, 112 B10001000, 113 B01110000, 114 B10001000, 115 B10001000, 116 B01110000,B00000000}, 117 //6, 118 119 {B01110000, //9 120 B10001000, 121 B10001000, 122 B01111000, 123 B00001000, 124 B00010000, 125 B01100000,B00000000}, 126 //6, 127 128 {B00000000, //blank 129 B00000000, 130 B00000000, 131 B00000000, 132 B00000000, 133 B00000000, 134 B0000000,B00000000} 135}; 136 137void setup() 138{ 139 // Wakeup call for MAX72XX 140 lc.shutdown(0, false); 141 lc.shutdown(1, false); 142 lc.shutdown(2, false); 143 lc.shutdown(3, false); 144 145 // Set the brightness to a medium values 146 lc.setIntensity(0, 2); 147 lc.setIntensity(1, 2); 148 lc.setIntensity(2, 2); 149 lc.setIntensity(3, 2); 150 151 // Clear display 152 lc.clearDisplay(0); 153 lc.clearDisplay(1); 154 lc.clearDisplay(2); 155 lc.clearDisplay(3); 156 157 // Start the I2C interface 158 Wire.begin(); 159 160} 161 162void loop() 163{ 164 165int i=0; 166int j=0; 167 168const int blank_space=10;//position of blank space in my_array[][] 169 170static int hours=0; 171static int minutes=0; 172static int hours_tens=0; 173static int hours_units=0; 174static int minutes_tens=0; 175static int minutes_units=0; 176static bool decimal_point_on =true; 177 178minutes=Clock.getMinute(); 179hours=Clock.getHour(h12, PM); 180 181hours_tens=(hours/10); 182hours_units=(hours%10); 183minutes_tens=(minutes/10); 184minutes_units=(minutes%10); 185 186//blank leading zero's 187if (hours<10){hours_tens=blank_space;} 188 189//Function format:display_write(row,data,display_number,total_displays) 190//row = an individual line on an individual display (1=top line 8=bottom line) 191//data = 8 bits - bit=1 led on, bit=0 led off 192//display_number = rightmost display is 0 count upwards to the display you wish to address 193//total_displays = the total number of displays you have chained together 194 195//write data to displays 196for (i=0;i<10;i++){ 197for(j=0;j<8;j++){display_write(j+1,my_array[minutes_units][j],0,total_displays);} 198 199for(j=0;j<8;j++){display_write(j+1,my_array[minutes_tens][j],1,total_displays);} 200 201 202for(j=0;j<8;j++){switch(j){case 3:display_write(j+1,decimal_point(my_array[hours_units][j],decimal_point_on),2,total_displays);break; 203 case 4:display_write(j+1,decimal_point(my_array[hours_units][j],decimal_point_on),2,total_displays);break; 204 default:display_write(j+1,my_array[hours_units][j],2,total_displays);break;} } 205 206for(j=0;j<8;j++){display_write(j+1,my_array[hours_tens][j],3,total_displays);} 207 208} 209 210 211 212delay(200); 213 214decimal_point_on=!decimal_point_on; 215 216} 217 218// My_functions 219 220//function to add or remove decimal point for particular display segment 221byte decimal_point(byte x,bool y){if (y){x|=0b00000010;}else{x&=0b11111101;}return x;} 222 223 224// Function to transfer a row of data to specific display 225void display_write(int row, int value, int display_number, int total_displays) { 226 227int i=0; 228 229//transfer data to display_number only 230for (i=total_displays;i>=0;i--){if (i==display_number){lc.setRow(i,row,value);} } //void setRow(int addr, int row, byte value); 231 232} 233 234// End of program 235
LCD clock via I2C
c_cpp
1/* 2 * 3 * Read time from Ds3231 real time clock and display on LCD 4 in 12 hour format 5 * December 2021 6 * 7 * 8*/ 9 10#include <Wire.h> 11 // Comes with Arduino IDE 12#include <LiquidCrystal_I2C.h> 13 14//for the clock 15#include 16 <DS3231.h> 17DS3231 Clock; 18bool h12; 19bool PM; 20 21// set the LCD address 22 to 0x27 for most displays 23// A FEW use address 0x3F 24LiquidCrystal_I2C lcd(0x3F,16,2); 25 26void 27 setup() 28{ 29 30 lcd.init(); 31 lcd.init(); 32 lcd.backlight(); 33 34// 35 NOTE: Cursor Position: (CHAR, LINE) start at 0 36 lcd.setCursor(0,0); 37 lcd.print("The 38 time is:"); 39 40} 41 42void loop() 43{ 44 lcd.setCursor(0,1); 45 46 47 // hour, minute, second 48 lcd.print(Clock.getHour(h12, PM), DEC); 49 lcd.print(':'); 50 51 lcd.print(Clock.getMinute(), DEC); 52 lcd.print(':'); 53 lcd.print(Clock.getSecond(), 54 DEC); 55 56 // Add AM/PM indicator 57 if (h12) { 58 if (PM) { 59 lcd.print(" 60 PM "); 61 } else { 62 lcd.print(" AM "); 63 } 64 } else { 65 66 lcd.print(" 24h "); 67 } 68 69}// end of code 70
Binary clock
c_cpp
1/* 2 * 3 * Read time from Ds3231 real time clock and display on 1*Maxx7219 4 display in binary 5 * December 2021 6 * 7 * 8*/ 9 10//for the clock 11#include 12 <DS3231.h> 13#include <Wire.h> 14DS3231 Clock; 15bool h12; 16bool PM; 17 18 19// 20 For the display 21#include "LedControl.h" 22/* 23 ***** Pin numbers for LedControl 24 ***** 25 pin 11 is connected to the DataIn 26 pin 13 is connected to the CLK 27 28 pin 10 is connected to LOAD / CS 29 We have 4* MAX72XX. 30*/ 31const int total_displays=4; 32LedControl 33 lc = LedControl(11, 13, 10, total_displays); 34 35 36 37void setup() 38{ 39 40 // Wakeup call for MAX72XX 41 lc.shutdown(0, false); 42 43 // Set the brightness 44 to a medium values 45 lc.setIntensity(0, 2); 46 47 // Clear display 48 lc.clearDisplay(0); 49 50 51 // Start the I2C interface 52 Wire.begin(); 53 54 Serial.begin(9600); 55 56 57} 58 59void loop() 60{ 61 62int i=0; 63int j=0; 64 65const int blank_space=10;//position 66 of blank space in my_array[][] 67 68static int hours=0; 69static int minutes=0; 70static 71 int hours_tens=0; 72static int hours_units=0; 73static int minutes_tens=0; 74static 75 int minutes_units=0; 76static bool decimal_point_on =true; 77 78minutes=Clock.getMinute(); 79hours=Clock.getHour(h12, 80 PM); 81 82hours_tens=(hours/10); 83hours_units=(hours%10); 84minutes_tens=(minutes/10); 85minutes_units=(minutes%10); 86 87Serial.println(hours_tens,BIN); 88Serial.println(hours_units,BIN); 89Serial.println(minutes_tens,BIN); 90Serial.println(minutes_units,BIN); 91 92//blank 93 leading zero's 94if (hours<10){hours_tens=0;} 95 96lc.setColumn(0,6,hours_tens);//setColumn(address,column,value) 97lc.setColumn(0,5,hours_units);//setColumn(address,column,value) 98lc.setColumn(0,4,minutes_tens);//setColumn(address,column,value) 99lc.setColumn(0,3,minutes_units);//setColumn(address,column,value) 100 101delay(1000); 102 103 104} 105 106 107 108// End of program 109
Binary clock
c_cpp
1/* 2 * 3 * Read time from Ds3231 real time clock and display on 1*Maxx7219 display in binary 4 * December 2021 5 * 6 * 7*/ 8 9//for the clock 10#include <DS3231.h> 11#include <Wire.h> 12DS3231 Clock; 13bool h12; 14bool PM; 15 16 17// For the display 18#include "LedControl.h" 19/* 20 ***** Pin numbers for LedControl ***** 21 pin 11 is connected to the DataIn 22 pin 13 is connected to the CLK 23 pin 10 is connected to LOAD / CS 24 We have 4* MAX72XX. 25*/ 26const int total_displays=4; 27LedControl lc = LedControl(11, 13, 10, total_displays); 28 29 30 31void setup() 32{ 33 // Wakeup call for MAX72XX 34 lc.shutdown(0, false); 35 36 // Set the brightness to a medium values 37 lc.setIntensity(0, 2); 38 39 // Clear display 40 lc.clearDisplay(0); 41 42 // Start the I2C interface 43 Wire.begin(); 44 45 Serial.begin(9600); 46 47} 48 49void loop() 50{ 51 52int i=0; 53int j=0; 54 55const int blank_space=10;//position of blank space in my_array[][] 56 57static int hours=0; 58static int minutes=0; 59static int hours_tens=0; 60static int hours_units=0; 61static int minutes_tens=0; 62static int minutes_units=0; 63static bool decimal_point_on =true; 64 65minutes=Clock.getMinute(); 66hours=Clock.getHour(h12, PM); 67 68hours_tens=(hours/10); 69hours_units=(hours%10); 70minutes_tens=(minutes/10); 71minutes_units=(minutes%10); 72 73Serial.println(hours_tens,BIN); 74Serial.println(hours_units,BIN); 75Serial.println(minutes_tens,BIN); 76Serial.println(minutes_units,BIN); 77 78//blank leading zero's 79if (hours<10){hours_tens=0;} 80 81lc.setColumn(0,6,hours_tens);//setColumn(address,column,value) 82lc.setColumn(0,5,hours_units);//setColumn(address,column,value) 83lc.setColumn(0,4,minutes_tens);//setColumn(address,column,value) 84lc.setColumn(0,3,minutes_units);//setColumn(address,column,value) 85 86delay(1000); 87 88} 89 90 91 92// End of program 93
LCD clock via I2C
c_cpp
1/* 2 * 3 * Read time from Ds3231 real time clock and display on LCD in 12 hour format 4 * December 2021 5 * 6 * 7*/ 8 9#include <Wire.h> // Comes with Arduino IDE 10#include <LiquidCrystal_I2C.h> 11 12//for the clock 13#include <DS3231.h> 14DS3231 Clock; 15bool h12; 16bool PM; 17 18// set the LCD address to 0x27 for most displays 19// A FEW use address 0x3F 20LiquidCrystal_I2C lcd(0x3F,16,2); 21 22void setup() 23{ 24 25 lcd.init(); 26 lcd.init(); 27 lcd.backlight(); 28 29// NOTE: Cursor Position: (CHAR, LINE) start at 0 30 lcd.setCursor(0,0); 31 lcd.print("The time is:"); 32 33} 34 35void loop() 36{ 37 lcd.setCursor(0,1); 38 39 // hour, minute, second 40 lcd.print(Clock.getHour(h12, PM), DEC); 41 lcd.print(':'); 42 lcd.print(Clock.getMinute(), DEC); 43 lcd.print(':'); 44 lcd.print(Clock.getSecond(), DEC); 45 46 // Add AM/PM indicator 47 if (h12) { 48 if (PM) { 49 lcd.print(" PM "); 50 } else { 51 lcd.print(" AM "); 52 } 53 } else { 54 lcd.print(" 24h "); 55 } 56 57}// end of code 58
Downloadable files
Top view of clock board
Top view of clock board

Circuit diagram of clock board
Circuit diagram of clock board

Circuit diagram of clock board
Circuit diagram of clock board

Comments
Only logged in users can leave comments