int dataPin = 2;
int latchPin = 3;
int clockPin = 4;
void setup()
{
  pinMode(dataPin, OUTPUT);   //Configure each IO Pin
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}

void loop()
{
  for (int n = 0; n < 256; n++)
  {
    digitalWrite(latchPin, LOW);  //Pull latch LOW to start sending data
    shiftOut(dataPin, clockPin, MSBFIRST, n);  //Send the data
    digitalWrite(latchPin, HIGH);  //Pull latch HIGH to stop sending data
    delay(500);
  }
}