Help with Shift Registers

Hello, I am new to microcontrollers and am trying to understand all the different components. What i would like to do is have a push button switch connected to an input pin on the arduino when i push that button i want it to set a random pin (in the range i give it) to high. Seems like i can do this without a shift register but from my searching it might be better to do it with one. Does anyone have any psuedo code or even a sample as to how i can do this. Thanks

Define the pins you want to use in an array. Then generate a random number and use that as an array index to use in the digitalWrite() statement.
There is no need to use a shift register.

So lots of new words to look up. :wink:

Generate a random with just the random() function?
Suppose down the road i need more pins than i have available on the arduino, would i then do the same thing, generate a random decimal number and use that in the shiftOut()?
Thanks for the response

with just the random() function?

yes. :slight_smile:

would i then do the same thing

Yes, use it to set a bit (bitSet()) in a byte then shift that byte out using a shift register. If you just send out a random number to a shift register any number of bits can be set high depending on the number. You can cascade shift registers and bytes to make it as long as you like.

Yes when you need more OUTPUT pins, then you need a shift register. Meanwhile you can just do what Grumpy_Mike suggests, get the basic concept into code. Make it work, worry about expanding later. If you want, you can order some 74HC595 shift registers so when you need them, you don't have to wait for them to arrive.

thanks again, will try it tonight