int latchPin = 12; //latch pin -> last step before we see output --> when HIGH, data from shift register are copied to storage
int clockPin = 13; // clock pin -> keep shift register and arduino synchronised
int dataPin = 11; // used to output data
// Note: Shift registers are flip flops that store multiple bits of data that can be move in and out of registers by applying clock pulses
// encoding characters 0-F of common-anode 7-segment Display
byte num[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 0x83,
0xc6, 0xa1, 0x86, 0x8e};
void setup() {
// put your setup code here, to run once:
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// cycle through display 0-F
for(int i = 0; i <= 0x0f; i++){
// output low level to latchpin
digitalWrite(latchPin, LOW);
// Send serial data to 74HC595
shiftOut(dataPin, clockPin, MSBFIRST, num[i]);
// Output high level to latchPin, and 74HC595 will update data to parallel output port
digitalWrite(latchPin, HIGH);
delay(1000); // delay 1000ms
}
}