Hello again everybody!
I have 6 74HC595 Shift Registers daisy chained... Is that too many? It seems to be acting screwy. By "screwy" I mean it is not lighting the LEDs I would expect, when I would expect it to do so. Perhaps I am missing something code-wise? I have tested and verified the chips and connections individually, and all is well. Additionally, when the arduino 1st loads I have noticed that the intended LEDs flicker for a split second, then never come on again. OR after a reset the intended LEDs will come on if they are in registers 4, 5, or 6- but then they just stay on ignoring the ender(); function altogether.
Here is my debug code, to try to figure out what is going on:
const int data = 6;
const int clock = 7;
const int latch = 8;
const int outputenable = 5;
const int masterreset = 4;
const byte shiftoutarray[] = {0, 1, 2, 4, 8, 16, 32, 64, 128}; // NOTE: I only want to light one LED from any given register at a time, which is why these bytes are like this
const int ON = HIGH;
const int OFF = LOW;void setup() {
pinMode(data, OUTPUT); //begin shift register pinmodes
pinMode(clock, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(outputenable, OUTPUT);
pinMode(masterreset, OUTPUT);
Serial.begin(9600);digitalWrite(masterreset, 0);
digitalWrite(outputenable, 1);
delay(20);digitalWrite(masterreset, 1);
digitalWrite(outputenable, 0);
digitalWrite(latch, 0);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
digitalWrite(latch, 1);
digitalWrite(outputenable, 1);delay(20);
digitalWrite(outputenable, 0); // All of this was just to make sure the registers are clear at startup}
void loop() {
light();
delay(5000);ender();
delay(1000);}
void light()
{
digitalWrite(latch, 0);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[1]); //This should light the 1st LED in my 3rd register
shiftOut(data, clock, MSBFIRST, shiftoutarray[4]); //This should light the 4th LED in my 2nd register
shiftOut(data, clock, MSBFIRST, shiftoutarray[5]); //This should light the 5th LED in my 1st register
digitalWrite(latch, 1);
Serial.println("should be lit");}
void ender()
{
digitalWrite(latch, 0); // This should turn off all lights on all registers... it doesn't for some reason- they just stay on...
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
shiftOut(data, clock, MSBFIRST, shiftoutarray[0]);
digitalWrite(latch, 1);
Serial.println("should be off");}
Any insight you can provide would be greatly appreciated!