#define DATA_PIN  8  // Pin connected to DS of 74HC595 and D8 of Arduino
#define LATCH_PIN 9  // Pin connected to STCP of 74HC595 and D9 of Arduino
#define CLOCK_PIN 10 // Pin connected to SHCP of 74HC595 and D10 of Arduino

// How many shift registers
#define NUM_SHIFT_REGS 8
#define true HIGH
#define false LOW

const uint8_t numOfRegisterPins = NUM_SHIFT_REGS * 8;

bool registers[numOfRegisterPins];

void SR_Init() {
  pinMode(DATA_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);
  pinMode(LATCH_PIN, OUTPUT);
  clearRegisters();
  writeRegisters();
}

bool toggle = false;

void clearRegisters() {
  // Reset all register pins
  for (int i = numOfRegisterPins; i >= 0; i--) {
    registers[i] = LOW;
  }
}

void setRegisterPin(int index, int value) {
  // Set an individual pin HIGH or LOW
  registers[index] = value;
}

void writeRegisters() {
  // Set and display registers
  digitalWrite(LATCH_PIN, LOW);

  for (int i = numOfRegisterPins; i >= 0; i--) {
    digitalWrite(CLOCK_PIN, LOW);
    digitalWrite(DATA_PIN, registers[i]);
    digitalWrite(CLOCK_PIN, HIGH);
  }

  digitalWrite(LATCH_PIN, HIGH);
}

void write(int pinNumber, bool mode)
{
  registers[pinNumber] = mode;
  writeRegisters();
}

void setup() {
  SR_Init();
}

void loop() {
  blinkCenter();
  blinkCenter2();
  blinkCenter();
  blinkCenter2();
  blinkCenter();
}

void blinkCenter() {
  write(0, HIGH);
  write(1, HIGH);
  write(2, HIGH);
  write(3, HIGH);
  write(4, HIGH);
  write(5, HIGH);
  write(6, HIGH);
  write(7, HIGH);
  delay(300);
  write(0, LOW);
  write(1, LOW);
  write(2, LOW);
  write(3, LOW);
  write(4, LOW);
  write(5, LOW);
  write(6, LOW);
  write(7, LOW);
  delay(300);
}

void blinkCenter2() {
  write(0, HIGH);
  write(1, HIGH);
  write(2, HIGH);
  write(3, HIGH);
  write(4, HIGH);
  write(5, HIGH);
  write(6, HIGH);
  write(7, HIGH);
  delay(600);
  write(0, LOW);
  write(1, LOW);
  write(2, LOW);
  write(3, LOW);
  write(4, LOW);
  write(5, LOW);
  write(6, LOW);
  write(7, LOW);
  delay(600);
}
74HC595
74HC595
74HC595
74HC595
74HC595
74HC595
74HC595
74HC595