sorry Grumpy_Mike. i was got confused with for loop. My mistake.
Now check the whole code. my last question is if your code place in inside the for loop(means above the digitalWrite(ClockPin,LOW); ) line then it works. If i place your code at the below " void loop() " then it also work fine.
Is it ok to create two loops. One for Xor operation and second for shifting data to register.
int latchPin = 5;
int ClockPin = 6;
int dataPin = 4;
int led[] = {0,1,1,0,0,1,1,0};
int ledState[] = {0,1,1,0,0,1,1,0};
void setup()
{
pinMode(latchPin,OUTPUT);
pinMode(ClockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
for(int i = 0; i<8; i++){
if(led[i] == 1) ledState[i] ^= 1; // this will blink all the LEDs in the pattern
}
delay(300);
digitalWrite(latchPin, LOW);
for(int i=0;i<8;i++)
{
digitalWrite(ClockPin,LOW);
digitalWrite(dataPin,ledState[i]);
digitalWrite(ClockPin,HIGH);
}
digitalWrite(latchPin, HIGH);
}