/*
74HC595 Arduino Shift Register example for Wokwi
Copyright (C) 2021, Uri Shaked
License: MIT.
*/
const int dataPin = 2; /* DS */
const int clockPin = 3; /* SHCP */
const int latchPin = 4; /* STCP */
const int dataPin2 = 5; /* DS */
const int clockPin2 = 6; /* SHCP */
const int latchPin2 = 7; /* STCP */
const int zero = B10100000;
const int one = ~B00000101;
const int two = B11000100;
const int three = ~B00101111;
const int four = ~B01100101;
const int five = ~B01101110;
const int six = B10000001;
const int seven = ~B00000111;
const int eight = B10000000;
const int nine = B10010000;
int timer = 0;
void setup() {
for (int i = 2; i <= 7; i++) {
pinMode(i, OUTPUT);
}
}
int num[10] = {zero, one, two, three, four, five, six, seven, eight, nine};
int col[4] = {B11000000, B10100000, B10010000, B10001000};
void loop() {
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 10; i++) {
updateLED(col[j], num[i]);
}
}
}
void updateLED(int disp, int pattern){
digitalWrite(latchPin2, LOW);
shiftOut(dataPin2, clockPin2, LSBFIRST, disp);
digitalWrite(latchPin2, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, pattern);
digitalWrite(latchPin, HIGH);
delay(300);
}