> For example im connecting the 11pin (which is first input pin) with ground
> to the 9v battery
> and, in while(1) loop i am reading the status of inputs in parraler port.
> I cant see any change when connecting/disconnecting the input pin from
> battery ;((
> Of course, i ses a change when i connect the pin to the ground, but this is
> not what i need :(
What you are experiencing is perfectly normal. The input pins of your
parallel port are designed to have a very high impedance. The logic of
the parallel port looks at the voltage of the pin, and depending on the
value of the voltage, it decides that it is seeing a 1 or a 0.
If you connect the pin to a 5V potential (the - of a 5V power supply to
the ground, and the + terminal to the input pin), you change the voltage
between ground and the input pin to 5V, and the input is a 1.
If you connect the input pin directly to ground, you are putting a 0V
voltage between ground and the input pin, and the input is a 0.
However, if you don't connect anything at all to the input pin, it stays
at its old value, which is exactly what you are experiencing.
To solve your problem, I would suggest using a pulldown resistor. That
is, you put a resistor between the input pin and ground. That way, if
nothing else is connected, the input pin discharges to 0V through the
resistor and you get a 0. However, when you supply 5V to the pin, the
pin is brought to 5V (and there is a little leakage current through the
resistor that you shouldn't worry about) and you get a 1. Bingo, this is
what you want.
The pulldown resistor acts a bit like a spring that brings your pin back
to 0 when you are done driving it (don't push the analogy too far
though). I would suggest a few kilo-ohms for the resistor.
As a side note, I am worried about the 9V you are using on your parallel
port. You could damage it as it is only supposed to be used with up to
5V. You could put a resistor that is the same size as your pulldown
resistor between the battery and the input pin to get that voltage
divided by 2, which should be fine.
The circuit I would do is presented below. Of course I decline all
formal responsibility should your computer blow up or your stock
suddenly crash... :-)
where A is the place where your battery is connected or not, B is the
input pin on the parallel port, and GND is the ground (- terminal of the
battery, and ground of the parallel port).
-- To unsubscribe, send mail to: firstname.lastname@example.org --
-- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2b29 : Thu Nov 21 2002 - 21:21:07 EST