Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

GPIO pin for both input and output


  • Please log in to reply
3 replies to this topic

#1 scottyb84

scottyb84

    New Member

  • Members
  • Pip
  • 2 posts

Posted 07 March 2011 - 02:29 AM

Hey guys, I've been browsing the forums for a while, had my Plus for a few weeks now and haven't gotten any major projects going quite yet, but I'd like to interface with a temperature sensor (DS1620) that uses a 3-wire interface (clock, data, reset). I'm not too concerned about speed so bitbanging is fine by me, but I'm wondering if I can use a single GPIO pin for both reading and writing data to. Is this even possible? Can I create an output port, write the data, dispose it, then create the input port on the same pin to read the data? I basically just want to disable the output port from driving the line when I need to treat it as an input port. Any suggestions? Thanks, Scott

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 07 March 2011 - 07:45 AM

Hi Scott, Yes, you can absolutely use a single port for both writing and reading data. First option: create an OutputPort, use it, dispose of it, create an InputPort instead, use it, dispose it, repeat. Second option: create a TristatePort <-- this will let you change the mode between read and write on the fly. Welcome to the Netduino community, Chris

#3 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 07 March 2011 - 03:04 PM

I suggest you use the TristatePort class. It is faster than creating an output and disposing then creating an input. Here is an example of how I used it http://forums.netdui...de-is-included/ and http://forums.netdui...ch__1#entry6511

#4 scottyb84

scottyb84

    New Member

  • Members
  • Pip
  • 2 posts

Posted 07 March 2011 - 11:57 PM

TristatePort is exactly what I was looking for - thanks for the help! -Scott




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.