1
\$\begingroup\$

I am designing a measurement system based on a single pin. When the pin is connected to GND, it means move right. If the pin is not connected to anything, no action happens.

The system was contolled by button switch originally, but I want to control it with a mouse such that when the mouse moves right, the pin is connected to GND, and when the mouse don't move, the pin is connected to nowhere.

I have tried to connect the pin to an Arduino UNO's 3rd pin. Whenever mouse's rightward moving is detected, the 3rd pin should be connected to ground. When the mouse's moving is something else than rightward, the Arduino UNO's 3rd pin should work as if it was not connected.

I think that making the 3rd pin act as GND can be done by analogWrite(3,0), but how can I simulate "connected nowhere"?

\$\endgroup\$
  • 1
    \$\begingroup\$ Did you copy and paste this from somewhere? The formatting it horrible, can you make it easier to read? \$\endgroup\$ – Kellenjb Jun 12 '11 at 18:10
  • \$\begingroup\$ @Kellenjb - fixed. \$\endgroup\$ – Kevin Vermeer Jun 20 '11 at 19:18
1
\$\begingroup\$

It sounds more like you have a pull-up resistor somewhere. When the pin is disconnected the resistor actually pulls it up to the Vcc causing current to flow from Vcc into the input causing a logic high. When the pin is linked to ground the power flows through the resistor and down to ground bypassing the input, causing a logic low.

A lot of MCUs have these pull-up resistors built-in and can be enabled/disabled in software.

Applying a logic "high" (linking to Vcc), or outputting a logic '1' from an output port, should give the same result as disconnecting the pin.

\$\endgroup\$
2
\$\begingroup\$

I'm not Arduino user, but I know that AVRs (like many other microcontrollers) have so-called high impedance state.

There is explanation how to use it on Arduino here. So I'd try with PinMode(pinno, input). The high impedance state should left the pin floating and be as close as possible to non-conncted pin as you can get.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.