byte digits[] = {0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b};
int dataPin = 2;
int clockPin = 3;
int latchPin = 4;
int cathode1 = 5;
int cathode2 = 6;
int cathode3 = 7;
void setup() {
// put your setup code here, to run once:
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(cathode1, OUTPUT);
pinMode(cathode2, OUTPUT);
pinMode(cathode3, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int num = 321;
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digits[num % 10]);
digitalWrite(latchPin, HIGH);
digitalWrite(cathode1, LOW);
digitalWrite(cathode2, HIGH);
digitalWrite(cathode3, HIGH);
delay(10);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digits[(num/10) % 10]);
digitalWrite(latchPin, HIGH);
digitalWrite(cathode1, HIGH);
digitalWrite(cathode2, LOW);
digitalWrite(cathode3, HIGH);
delay(10);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digits[(num/100) % 10]);
digitalWrite(latchPin, HIGH);
digitalWrite(cathode1, HIGH);
digitalWrite(cathode2, HIGH);
digitalWrite(cathode3, LOW);
delay(10);
}