I decided to make a simple example to print on a 4-digit display by 74HC164 shift registers, because I couldn't find any examples of using these shift registers on the internet. I found examples that used the 74HD595 shift register but I needed the 74HC164.
https://www.facebook.com/fradut/videos/704017387419250/
I used an LFD039AUE-102A display, which has the internal diagram below:
I used 2 shift registers CD74HC164E:
The connection to Arduino UNO is as follows:
I used the following code to make the timer:
/*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);
}
Comments