Yeah I thought I'd gotten it working with only two shift registers on a breadboard, but maybe I didn't test that thoroughly enough before moving on to soldering up a more permanent version. Lesson learned I guess.
Here's a diagram of what (I believe) I have wired up: [edited to fix diagram]
http://img3.imageshack.us/img3/4592/circuitdiagram.png
And the code I'm uploading:
//======================================================
// Shift Register Demo
//======================================================
//Configuration
#define LATCH 8
#define CLOCK 12
#define DATA 11
void shiftOut(int dataPin, int clockPin, byte output)
{
//Enable output on the clock pin and data pin
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
//Just in case
digitalWrite(clockPin, LOW);
digitalWrite(dataPin, LOW);
//Loop through each of the bits
for(int i = 7; i>=0; --i)
{
digitalWrite(clockPin, LOW);
int pinState;
if(output & (1 << i))
pinState = HIGH;
else
pinState = LOW;
digitalWrite(dataPin, pinState);
digitalWrite(clockPin, HIGH);
digitalWrite(dataPin, LOW);
}
digitalWrite(clockPin, LOW);
}
void setup()
{
//Configure the latch pin for output
pinMode(LATCH, OUTPUT);
}
void loop()
{
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, B00000001);
shiftOut(DATA, CLOCK, B00000000);
shiftOut(DATA, CLOCK, B00000000);
shiftOut(DATA, CLOCK, B00000000);
shiftOut(DATA, CLOCK, B00000000);
shiftOut(DATA, CLOCK, B00000000);
digitalWrite(LATCH, HIGH);
}
}
A couple other observations:
- If I disconnect the wire connecting the circuit to the +5v pin on the arduino the behavior doesn't change at all
- Along those lines, the after a little messing around I figured out that the High/Low state of the output pins of the last four registers are always the same as the state of the latch pin on the first register (even when the +5V wire is disconnected)
- The shift registers are M74HC595B1R registers... not sure if that is important, I'm kind of going off the diagram showed on the ShiftOut tutorial page to identify which pin is which.
Also, one more question: What is the difference between using the shiftOut function (http://www.arduino.cc/en/Reference/ShiftOut) and the function posted in my code (I've tried both, but the tutorial uses the above function for the multiple register example)?
Thanks again for taking the time to help me with this stuff, I'm new to debugging circuits.