int clockPin = 2;
int latchPin = 3;
int dataPin = 4;
int outputEnablePin = 5;
byte leds = 0;
void setup(){
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(outputEnablePin, OUTPUT);
}
void loop() {
leds = 0B11111111;
updateShiftRegister();
delay(500);
for (byte b = 255; b > 0; b--){
analogWrite(outputEnablePin, b);
delay(10);
}
}
void updateShiftRegister(){
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}