Shift Registers...

Hey I think that there is a part like this but I'm not sure what it is exactly called... Shift registers can basically expand your I/O pins with a clock and timed output states, so isn't there an inverse of a shift register where you can send out clock signals and stuff then read the input states? Basically instead of sending data through a shift register you recieve data like sensor or switch inputs? If anyone knows if these things exist or what they r called that would be great :) this is probably a noob hardware question.

what you need is a shift register! you need a parallel in/ serial out register. Take a look at these pages: http://www.arduino.cc/playground/Learning/4051 http://www.arduino.cc/playground/Code/ShiftRegSN74HC165N

So these are basically Shift registers with programs that allow you to input data instead of output right?

It's not a "program", it's the hardware, but yes.

Think of it like a bucket brigade: in a serial-in/parallel-out chip, you pass the buckets in one at a time from one end. When you signal the chip to "latch", each person sets his bucket down in front of him.

For parallel-in/serial-out, the "load" signal tells each person to pick up the bucket in front of him, and pass them out the end one at a time as you toggle the clock line.

Ran

Weren't there some LS TTL 4 bit register chips that could do both SIPO and PISO functions with the right control bits set? Too many years and dead brain cells to recall exactly and too lazy to do the research. ;)

Lefty

LS TTL 4 bit register chips that could do both SIPO and PISO functions with the right control bits set?

The CMOS one is the 4035, I don't know of a TTL one.

Also look at data selectors or multiplexers like:-

74150: 16-Line to 1-Line Data Selector/Multiplexer

74151: 8-Line to 1-Line Data Selector/Multiplexer

74152: 8-Line to 1-Line Data Selector/Multiplexer

74153: Dual 4-Line to 1-Line Data Selector/Multiplexer

74154: 4-Line to 16-Line Decoder/Demultiplexer

74155: Dual 2-Line to 4-Line Decoder/Demultiplexer

74156: Dual 2-Line to 4-Line Decoder/Demultiplexer with open collector outputs

74157: Quad 2-Line to 1-Line Data Selector/Multiplexer, Noninverting

74158: Quad 2-Line to 1-Line Data Selector/Multiplexer, Inverting

74159: 4-Line to 16-Line Decoder/Demultiplexer with open collector outputs

The old Nintendo Entertainment System (NES) used a CMOS shift register as an input device. It used a 4021 8-bit parallel-in, serial-out shift register insides the controller joypad to read the eight buttons and send the data to the console. The Super Nintendo (SNES) used two 4021 chips to read 12 buttons (four unused inputs).

I think the 74*299 functions as both SIPO/PISO.

Yep it does, I haven't used that one before.

I recently bought some of the *299s thinking their "Universal" abilities would be useful some day. I'll take a closer look at the data sheet after work.

What I think Azinman needs is an analog/digital multiplexer. Only because he mentioned reading sensors.

http://www.sparkfun.com/commerce/product_info.php?products_id=9056 I believe Grumpy pointed out this gem in the recent past.

For this device you would use 4 or 5 digital output pins on the arduino and 1 analog input pin. By connecting different switches, sensors, etc. to the multiplexer's inputs, you can select which one gets to the arduino analog input by addressing it with 4 digital pins.

There is an 8 input version as well I believe. EDIT: The 8 input version would only require 3 control inputs for the addressing.

So this one allows you to read data from up to 16 sensors. Is there any source code or examples on how to control the 4 digital pins?

All you need to do is assert a binary number on the pins (5V = 1, 0V = 0) corresponding to the multiplexer input you want to use. 0110 would address pin 6. So you choose 4 digital pins like 2 3 4 5 where pin 2 is S0 and pin 5 is S3. S0 is the LSB, so you would use a chunk of code like this:

// you want to address Channel 9 of the multiplexer. // you previously addressed S0 through S3 to the correct arduino I/O pins in setup().

digitalWrite( S0, HIGH ); digitalWrite( S1, LOW ); digitalWrite( S2, LOW ); digitalWrite( S3, HIGH);

This would be equivalent to a decimal number of 9, enabling channel 9 of the multiplexer and allowing whatever analog value present on it to be sent to the arduino. (There will be some error due to the 60ohm on resistance of the multiplexer)

EDIT: I'm an EE major not a CS major, and I haven't gotten far enough into arduino to be very good at programming. I would use a switch statement to choose which input to assert, very simple.