dimitarkino
Published

Arduino seven segment clock

Cool big red digit clock

IntermediateShowcase (no instructions)569
Arduino seven segment clock

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
MAX7219/MAX7221 LED Display Drivers
Maxim Integrated MAX7219/MAX7221 LED Display Drivers
×1
SparkFun 7-Segment Serial Display - Red
SparkFun 7-Segment Serial Display - Red
×2
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×3
Capacitor 10 µF
Capacitor 10 µF
×1
Capacitor 100 nF
Capacitor 100 nF
×1
Resistor 1k ohm
Resistor 1k ohm
×8
Resistor 10k ohm
Resistor 10k ohm
×3
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

7_segment_clock_7__0P3R06WZN2.png

Code

8.ino

Arduino
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 pin 12 is connected to the DataIn 
 pin 11 is connected to LOAD 
 pin 10 is connected to the CLK
 */
LedControl lc=LedControl(12,10,11,1);
const int seth = 4;
const int setm = 3;
const int setc = 2;

int second ;
 int minute ;
int hour ;

int correction = 0;


unsigned long previousMillis = 0;
const long interval = 1000;
 
  
void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,12);
  lc.clearDisplay(0);
}
void loop() { 
  if (digitalRead(seth)== HIGH){
   hour++;
   delay(200);
   if(hour>23){
    hour=00;
   }
  }
 if (digitalRead(setm)== HIGH){
   minute++;
   delay(200);
   if(minute>59){
    minute=00;
   }
  }
   if (digitalRead(setc)== HIGH){
   correction++;
   delay(200);
   if(correction>59){
    correction=00;
   }
  }
 unsigned long currentMillis = millis();
 if (currentMillis - previousMillis >= interval) {
   previousMillis = currentMillis;
 second++; 
 if(second>59)
 {
   minute++;
   second=00;
 }
 if(minute>59)
 {
   hour++;
   minute=00;
   second = second + correction;
 }
 if(hour>23) { hour=00; minute=00; second=correction; }
 }

lc.setDigit(0,1,hour % 10,true);
lc.setDigit(0,0,(hour - hour % 10) / 10,false);
lc.setDigit(0,3,minute % 10,false);
lc.setDigit(0,2,(minute - minute % 10) / 10,false);
lc.setDigit(0,5,second % 10,true);
lc.setDigit(0,4,(second - second % 10) / 10,false);
lc.setDigit(0,7,correction % 10,false);
lc.setDigit(0,6,(correction - correction % 10) / 10,false);  
}

Credits

dimitarkino

dimitarkino

1 project • 0 followers

Comments

Add projectSign up / Login