/*
   Arduino code for Individual control over each pin
   Support for 40+ 74HC595 8 bit shift registers
   http://bildr.org/2011/02/74hc595/
*/

#define DATA_PIN  8  // Pin connected to DS of 74HC595
#define LATCH_PIN 9  // Pin connected to STCP of 74HC595
#define CLOCK_PIN 10 // Pin connected to SHCP of 74HC595

// How many of the shift registers
#define NUM_SHIFT_REGS 2

byte m, n;

void setup() {
  pinMode(DATA_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);
  pinMode(LATCH_PIN, OUTPUT);
  n = B00000000;
  m = B00000000;

}

void loop() {
  bitSet(n, 5);
  writeRegisters();
}


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

  shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, m);
  shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, n);

  digitalWrite(CLOCK_PIN, HIGH);
  digitalWrite(LATCH_PIN, HIGH);
}
74HC595
74HC595