Hi, I have a project that uses a matrix of leds but first I wanted to get some experience with the 74hc595 (good thing I did). I took a code and wiring diagrams on the internet and tried to make it work but it doesn't work.
I have 2 74hc595 and did the test on both. the first one when the power is put on all the led are on and the first led is flashing but not turning all the way off. the second one when the power is on, only the first led is on and flashing. I have tested both on the same circuit.
/* ---------------------------------------------------------
* | Arduino Experimentation Kit Example Code |
* | CIRC-05 .: 8 More LEDs :. (74HC595 Shift Register) |
* ---------------------------------------------------------
*
* We have already controlled 8 LEDs however this does it in a slightly
* different manner. Rather than using 8 pins we will use just three
* and an additional chip.
*
*
*/
//Pin Definitions
//Pin Definitions
//The 74HC595 uses a serial communication
//link which has three pins
int data = 2;
int iclock = 3;
int latch = 4;
/*
* setup() - this function runs once when you turn your Arduino on
* We set the three control pins to outputs
*/
void setup()
{
pinMode(data, OUTPUT);
pinMode(iclock, OUTPUT);
pinMode(latch, OUTPUT);
}
/*
* loop() - this function will start after setup finishes and then repeat
* we set which LEDs we want on then call a routine which sends the states to the
* 74HC595
*/
void loop() // run over and over again
{
int delayTime = 100; //the number of milliseconds to delay between LED updates
for(int i = 0; i < 256; i++){
updateLEDs(i);
delay(delayTime);
}
}
/*
* updateLEDs() - sends the LED states set in ledStates to the 74HC595
* sequence
*/
void updateLEDs(int value){
digitalWrite(latch, LOW); //Pulls the chips latch low
shiftOut(data, iclock, MSBFIRST, value); //Shifts out the 8 bits to the shift register
digitalWrite(latch, HIGH); //Pulls the latch high displaying the data
}
I have tried 2 thing. first I have put the code from Kolaha in the arduino. the led on Q0 Q1 and Q2 where on but all the other led where dime.
The second thing i tried was to redo the wiring so it is more clear but now notting is working and it seems like it is all the same. also the resistor for the led are 1k ohm
the yellow are on q0, q2, q4, q6 and the green are on q1, q3, q5, q7. the red are the 5v and the black the grund. the white and blue are on the arduino io
edit: I have tried to use a led indicator to test if diferant place in the circuit avec 5v. ( led catode to a 1k resistor, 1k resistor to the ground and the anode to a wire) when i put the anode wire to 5V led works, also led is always on when on same colum as pin 8, 9, 10, mr and on 5v to 74hc595 wich seem okay
the 5v was passing in both the bottom and the top but the ground wasint on the bottom, I have put a jumper were the 2 blue lines are but it stil not working.
I thing i will redo the wiring
Edit: i found what it was, the ground jumper from top to buttom was missing, oups
the blue light is my testing led
I think it works!!! Kolaha, as I understand from simple test the matrix ledpattern in the code is putting the first 1 in q7 and i goes in decreassing order? is it because when the pin shift is activated, it push the first data to the next position?
so the matrix is shown on the led from right to left