Go Down

Topic: Least lines for 8 switches (Read 373 times) previous topic - next topic

Mike_W

I am building a robot with my son, giving it 8 bumpers that sense when things have been hit.  One or more could be hit at one time. Is there an IC I could add into this to track it with fewer lines.

I have also thought about a 2nd arduino so we have tons of cables.  Fairly new to this, Not new to programming, used to do small electronic projects (like this) 30+ years ago - and I don't recall all the details and the world has changed (for the better thanks to arduino)

groundfungus

#1
Jul 04, 2013, 03:59 pm Last Edit: Jul 05, 2013, 06:17 am by groundfungus Reason: 1
An I2C expander chip like PCF8574 or MCP23006 would work for you.  It would take 8 switches and use 2 lines for communication plus 1 optional line for an interrupt.  The interrupt will fire on any expander pin changing.  I think that the PCF8674 may be simpler to use but the MCP23008 is more versatile.  Plus, if you are using the I2C bus, you wouldn't need but 1 extra line for the interrupt.
EDIT: You can have 7 additional expander chips on the same 3 wires for a total of 64 inputs (or outputs mix and match).  It gets a bit more complicated if you want interrupts from all 8 chips, but from 1 or 2 not so much.

marco_c

A parallel to serial input converter like the 74HC165 is cheap, available and uses 3 lines to interface as many of these chips as you need (they cascade). Lots of examples (code and circuits) on how these are used. Each chip takes 8 bits in parallel and squirts them out as a serial stream that you can assemble into a byte at the Arduino end. Datasheet here http://www.nxp.com/documents/data_sheet/74HC_HCT165.pdf.

The reverse comms is done using the 74HC595 chip.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Go Up