mdraber
Created August 20, 2021 © LGPL

Creating clock with custom built 7 segment display - Part1

Cool looking clock where leds lighting individual segments are controlled by MAX7219 module

IntermediateFull instructions provided274
Creating clock with custom built 7 segment display - Part1

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
MAX7219 Module
×1
Custom PCB
Custom PCB
×1
Wide Angle LED
×30

Story

Read more

Schematics

Schematics

Code

Code to light all 30 leds of the custom seven segment display, one by one

Arduino
#include "LedControl.h"
LedControl lc=LedControl(11,13,12,1);
int RowBits; 

void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,10);
  lc.clearDisplay(0);
}

void loop() {
   for (int i=0;i<4;i++){
     RowBits=B10000000; 
     for (int j=0;j<9;j++){
       lc.setRow(0,0, RowBits); 
       RowBits = RowBits >>1;
       delay(150);
     } 
   }
 }

Code to fast count from 0 to 9999 on custom built 7 segment display

Arduino
#include "LedControl.h"
LedControl lc=LedControl(11,13,12,1);
int RowBits; 
int d1;
int d2;
int d3;
int d4;


void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,4);
  lc.clearDisplay(0);
  Serial.begin(9600);
}

void loop() {
 

  for (int i=0;i<10000;i++){
    d1=(int)i/1000;
    d2=((int)i/100*100-(int)i/1000*1000)/100;
    d3=((int)i/10*10-(int)i/100*100)/10;
    d4=i-(int)i/10*10;
    lc.setChar(0,0,d1,false);
    lc.setChar(0,1,d2,false);
    lc.setChar(0,2,d3,false);
    lc.setChar(0,3,d4,false);
    Serial.print(d1);
    Serial.print(d2);
    Serial.print(d3);
    Serial.println(d4);
    
    delay(20);
  }
 }

Credits

mdraber
50 projects • 74 followers
Contact

Comments

Please log in or sign up to comment.