[solved]74HC595 : Put the pin numbers in a certain order for it to work

Hello why i have to do

#define shiftClock 12 // 11
#define latchClock 8 // 12
#define serialData 11 // 14

or

#define shiftClock 10 // 11
#define latchClock 9 // 12
#define serialData 8 // 14

and

void writeRegister(byte n) { 
  digitalWrite(latchClock, LOW);
  shiftOut(serialData, shiftClock, MSBFIRST, n);//n : byte
  digitalWrite(latchClock, HIGH);
}

why i have a bad result with

#define shiftClock 9 // 11
#define latchClock 10 // 12
#define serialData 8 // 14

(there is other order)

It is important that instructions are give to the shift register in the correct order. I have added comments to your code explaining the commands sent to the shift register

void writeRegister(byte n) {
  digitalWrite(latchClock, LOW);  //get ready to receive data
  shiftOut(serialData, shiftClock, MSBFIRST, n);//n : byte  //here is the data but don't output it yet
  digitalWrite(latchClock, HIGH);  //all 8 bytes sent so move the data to the output pins
}

The shift register does not care which Arduino pins you use just that they are taken HIGH/LOW in the right order

Damn ! I failed a simple logic test :o

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.