const int dataPin = 2;   /* DS */
const int clockPin = 3;  /* SHCP */
const int latchPin = 4;  /* STCP */

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

int cnt=0;
int pattern1 = 0b11000011;
int pattern2 = 0b11100111;
void loop() {
  digitalWrite(latchPin, LOW);
  if(cnt==0) shiftOutManual(dataPin, clockPin, pattern1);
  if(cnt==1) shiftOutManual(dataPin, clockPin, pattern2);
  digitalWrite(latchPin, HIGH);
  delay(500);
  cnt++;
  if(cnt==2) cnt=0;
}

void shiftOutManual(int dataPin, int clockPin, uint8_t val) {
    for (int i = 0; i < 8; i++) {
        int bit = val & (1 << i); // Get the bit at position 'i'
        digitalWrite(dataPin, bit != 0 ? HIGH : LOW); // Set dataPin HIGH if bit is 1, else LOW

        // Pulse the clock pin
        digitalWrite(clockPin, HIGH);
        delayMicroseconds(1); // short delay to ensure the clock pulse is registered
        digitalWrite(clockPin, LOW);
    }
}
74HC595