View Single Post
  #1   Spotlight this post!  
Unread 19-02-2009, 13:09
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Using a GPIO pin for both input and output.

Our team would like to use an ultrasonic rangefinder that uses the signal pin for both input and output (ping control and echo are on the same data line).

How would you go about using WPILib to switch a GPIO pin between input and output? Specifically, I'd like to do something along the following lines:

Code:
 DigitalOutput ping(12);
 Counter echo(12);
 echo.SetSemiPeriodMode(true);

 /* ... */
 ping.Pulse(pingPulseWidth);
 double range = echo.GetPeriod();
This is very easy to do with most microcontrollers, but I can't see an easy way to do this with WPILib. Any tips from the WPI guys?
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
Reply With Quote