Does it matter which digital pins I hook up to a shift register?

Does it matter which digital pins go to the shift register inputs, or can they be any? My question stems from seeing the Arduino ShiftOut example which uses strobe on pin 8, serial in on pin 11 (PWM), and clock on pin 12.

I also saw another tutorial on lastminuteengineer.com which didn’t use those particular pins. But do the specific input pins need to be PWM/non-PWM pins or can any work?

Thanks

Any pins. I prefer SPI

#include <SPI.h>
byte ssPin = 10;
void setup(){
pinMode (ssPin, OUTPUT);
SPI.begin();
}
void loop(){
digitalWrite (ssPin, LOW);
SPI.transfer(0xAA);
digitalWrite (ssPin, HIGH);
digitalWrite (ssPin, LOW);
SPI.transfer(0x55);
digitalWrite (ssPin, HIGH);
}

D13 to SCLK
D11 to Serial data on
D10 to RCLK
OE/ to Gnd
SRCLR to +5

But do the specific input pins need to be PWM/non-PWM pins or can any work?

Any pins will work if you are bit-banging the output. If you choose to use SPI as illustrated by Crossroads then specific pins must be used

To explain further, you want a byte of data (8 bits) that is held or calculated in your sketch to appear on the 8 parallel output pins of the shift register. To get them there, the 8 bits have to be sent from the Arduino to the shift register one bit at a time, in serial form. The shift register can then re-assemble the 8 bits into a byte and that then appears on the 8 output pins. To do that, the Arduino has to break the byte down into its individual bits. There are two ways to do that.

One is to use a small piece of code contained in a standard shiftOut() function. When using this method, you can specify any pins you want for the data pin and the clock pin.

The second way is to use a part of the Arduino's built-in hardware called the SPI interface. The downside of the second method is that you can only use the pins that the SPI hardware is connected to inside the chip. The up side is that you are using hardware acceleration and it is, I don't know, probably at least 20x as fast.

For a single shift register, the extra speed of SPI probably won't make any noticeable difference, depending what your circuit is doing. But shift registers can be chained together to give more outputs. If you have 10 chained together, you might still not notice the extra speed of SPI. But if you have 100 shift registers chained together, then it would get really slow to use shiftOut(), and much faster and more efficient to use SPI.

This has nothing whatsoever to do with PWM. Is there a particular reason you thought it might?

Do you know what PWM is?

Note that all I/O pins on a UNO are digital pins. Some (pins 14 to 19) can be used as analog inputs if needed. :grinning: