Shop OBEX P1 Docs P2 Docs Learn Events
How can i use one io port for more than one sensor — Parallax Forums

How can i use one io port for more than one sensor

JanstrJanstr Posts: 4
edited 2013-10-06 15:48 in General Discussion
I am looking for a way to use one io port (eg on a STAMP 2 processor) for two or more sensors. The nummer of io ports on the different processors (STAMP,Propellor, ...) is limited and i wonder if there is an IC that i can use to direct the io port to different sensors?

Comments

  • xanaduxanadu Posts: 3,347
    edited 2013-10-06 12:49
    Which two sensors?
  • JanstrJanstr Posts: 4
    edited 2013-10-06 13:32
    Lets say we are using a boe-bot, and i would like to use different sensors like infrared, ultrasound and contact switches. And i also want to use one or more leds to indicatie what my program is doing. I soon run out of available io ports. So it would be nice if there is a way (lets say an IC) that can forward two different io ports on that IC depending on a value given to that IC.
  • FranklinFranklin Posts: 4,747
    edited 2013-10-06 14:35
  • Mike GreenMike Green Posts: 23,101
    edited 2013-10-06 15:48
    This one is easier to use with a BS2 since it has an SPI interface which uses the SHIFTOUT and SHIFTIN statements for control. The one Franklin mentioned uses an I2C interface which is directly supported by the BS2p/pe/px Stamps, but not directly by the BS2 which needs large subroutines to use it. There are also 16-bit versions of both of these I/O expanders. Infrared would be hard to do with these because of the 38KHz carrier needed. The PING))) also won't work as neatly, but these I/O expanders are great for contact switches and other slow on/off sensors.

    For input I/O expansion, also look at the 74HC165 shift register. They're cheap and easy to use. There are plenty of coding examples in the StampWorks Manual and in one of the Nuts and Volts Columns in Parallax's archive.
Sign In or Register to comment.