const int dataPin = 11; // DS on 74HC595
const int latchPin = 12; // ST_CP on 74HC595
const int clockPin = 13; // SH_CP on 74HC595
void setup() {
// Set pins to output mode
pinMode(dataPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop() {
// Count from 0 to 255 (covers all combinations of 8 bits)
for (int number = 0; number <= 255; number++) {
// Pull the latch LOW to start sending data
digitalWrite(latchPin, LOW);
// Shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
// Once all bits are sent, set latch HIGH to send data to storage register
digitalWrite(latchPin, HIGH);
// Delay for a bit so we can see the change
delay(500);
}
}