fradut
Published

Timer with CD74HC164E and LED display 4-digits 7-segments

Arduino uno calculate minutes and seconds from millis() and print on a 4 digits LED display using 2 shift registers CD74HC164E by 2 wire

IntermediateFull instructions provided48
Timer with CD74HC164E and LED display 4-digits 7-segments

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Walabot LFD039AUE-102A 4 digits LED display
×1
Texas Instruments CD74HC164E shift register
×1
Resistor 220 ohm
Resistor 220 ohm
×4

Hand tools and fabrication machines

Breadboard, 830 Tie Points
Breadboard, 830 Tie Points

Story

Read more

Code

Timer with 74HC164

Arduino
/*afisaj led*/

int clockPin = 8;
int dataPin  = 9;
unsigned long moment;
int zecm;
int unim;
int zecs;
int unis;

//Matricea digitilor - 0 la 9
byte num[] = {
  B00000011, // Zero
  B10011111, // One
  B00100101, // Two
  B00001101, // Three
  B10011001, // Four
  B01001001, // Five
  B01000001, // Six
  B00011111, // Seven
  B00000001, // Eight
  B00001001, // Nine
  B11111111, // None
};
byte dig[] = {
  B10000000, // One
  B01000000, // Two
  B00100000, // Three
  B00010000, // Four
};
byte nump[] = {
  B00000010, // Zero
  B10011110, // One
  B00100100, // Two
  B00001100, // Three
  B10011000, // Four
  B01001000, // Five
  B01000000, // Six
  B00011110, // Seven
  B00000000, // Eight
  B00001000, // Nine
};

void setup() {
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

}

void loop() {
  moment = millis();
  zecm = (moment / 600000) % 10;
  unim = (moment / 60000) % 10;
  zecs = ((moment % 60000) / 10000) % 10;
  unis = ((moment % 60000) / 1000) % 10;
  //zeci de secunde
  shiftOut(dataPin, clockPin, LSBFIRST, ~dig[0]);
  shiftOut(dataPin, clockPin, LSBFIRST, ~num[zecm]);
  delay(5);
  //secunde
  shiftOut(dataPin, clockPin, LSBFIRST, ~dig[1]);
  shiftOut(dataPin, clockPin, LSBFIRST, ~nump[unim]);
  delay(5);
  //zecimi de secunda
  shiftOut(dataPin, clockPin, LSBFIRST, ~dig[2]);
  shiftOut(dataPin, clockPin, LSBFIRST, ~num[zecs]);
  delay(5);
  //sutimi de secunda
  shiftOut(dataPin, clockPin, LSBFIRST, ~dig[3]);
  shiftOut(dataPin, clockPin, LSBFIRST, ~num[unis]);
  delay(5);
}

Credits

fradut

fradut

1 project • 1 follower

Comments

Add projectSign up / Login