Hello everyone, today i am doing a project controlling 64 leds with 2 74HC595Ns and a ardunio mega 2560. I need help on improving the code so that I can light an individual LED in the 64 bit array and I can control which one to light up. I am fairly knowledged with ardunio code so you can share any knowledge you have, I greatly appreciate it. Im using multi-colored LEDs (R G B W R G B W x eight ) red,green,blue and white. I soldered it my self and hooked up everything but Im having alot of trouble lighting up an LED i want. I tried to use this code but it lights up all over the place and the reds seem to be only lighting up, Getting the blue or white to light up is extremely tricky, but they do light up but I had no idea how it worked. Thank you for your time and help The picture below is extremely similar to the set up I am using except that the HIGH and LOW data pins are reversed. The leds I used are 3mm Leds.
//
//
This is the code
//
int latchPin = 6; //Pin connected to groundd
int clockPin = 5; //Pin connected to ground
int dataPin = 7; //Pin connected to ground
int latchPin2 = 3; //Pin connected to vcc
int clockPin2 = 2; //Pin connected to vcc
int dataPin2 = 4; //Pin connected to vcc
void setup() {
//output to control shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(latchPin2, OUTPUT);
pinMode(clockPin2, OUTPUT);
pinMode(dataPin2, OUTPUT);
}
void loop() {
digitalWrite(latchPin, LOW);
//Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
shiftOut(dataPin, clockPin, MSBFIRST, 132);
// shifting out the bits:
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin2, LOW);
//Send 0 0 0 0 0 0 0 0 (0) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
shiftOut(dataPin2, clockPin2, MSBFIRST, 145);
// shifting out the bits
digitalWrite(latchPin2, HIGH);
digitalWrite(latchPin, LOW);
//Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
shiftOut(dataPin, clockPin, MSBFIRST, 2);
// shifting out the bits:
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin2, LOW);
//Send 0 0 0 0 0 0 0 0 (0) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
shiftOut(dataPin2, clockPin2, MSBFIRST, 253);
// shifting out the bits
digitalWrite(latchPin2, HIGH);
}
Thank you again for your help.