Shift registers - other way around.

alexmath:
Here it is a funny debate here, seriously. It was useless using that if statement there instead of just reading the state of the button directly (never happend again, my fault :)). Now i have a few more questions here:

  1. Again this one: How can i stop the leds flashing at the beginning of the program? What do i have to write in the setup()?
  2. If right to left lighting up the leds is a little bit tricky, can you figure out how to light them from left to right using shiftOut function? I can do that preaty easy without involving the button, but when it comes to the button, shiftOut functinon shifts 8 bits at a time, whereas when i press the button is just only one.

You can try use bit shifting and a little bit math to move along the lit LEDs.

perhaps use a bitwise OR with Ox01 each time the loop() circles with the buttonPin HIGH
then shift the byte 'left' (every 80ms)
The progression this way can be right to left or left to right.

modified...

Something like this untested code.

void loop()
{      
  if(millis() > interval + previousMillis)
  {
    ledByte = ledByte << 1;
    if (digitalRead(button)==HIGH)
    {
      newByte = 0x01;
    }
    else
    {
      newByte = 0x00;
    }
    ledByte = ledByte | newByte;
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, latchPin, LSBFIRST, ledByte);
    digitalWrite(latchPin, HIGH);  
    previousMillis = millis();
  }
}

or with even fewer lines of code:

void loop()
{      
  if(millis() > interval + previousMillis)
  {
    ledByte = ledByte << 1;
    if (digitalRead(button)==HIGH) ledByte = ledByte + 1;
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, latchPin, LSBFIRST, ledByte);
    digitalWrite(latchPin, HIGH);  
    previousMillis = millis();
  }
}