int dadosPin = 0;
int latchPin = 1;
int clockPin = 2;

byte leds;

void atualizarRegistrador() {
  digitalWrite(latchPin, LOW);
  shiftOut(dadosPin, clockPin, LSBFIRST, leds );
  digitalWrite(latchPin, HIGH);
}

void setup() {
  pinMode(dadosPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
 }

void loop() {
  leds = 0;
  atualizarRegistrador();
  
  for (int i = 0; i < 8; i++) {
    bitSet(leds, i);
    atualizarRegistrador();
    delay(500);
     }
  
  for (int j = 8; j >= 0; j-- ) {
    bitClear(leds, j);
    atualizarRegistrador();
    delay(500);
  }
}


74HC595