Shop OBEX P1 Docs P2 Docs Learn Events
very strange pin values getting read when nothing is plugged into the pin — Parallax Forums

very strange pin values getting read when nothing is plugged into the pin

qdoggmetsqdoggmets Posts: 14
edited 2009-11-30 14:09 in Learn with BlocklyProp
hi,

i plugged in my keypad, which i talked about in this thread http://forums.parallax.com/showthread.php?p=858329

i have the x and y pins connected for the anode and cathode as well as 2/8 data pins. my program is running a debug function to display the pin values.

i repeat again. i only have 2 leads going to the pin outs on the basic stamp. they are plugged into pin out 0 and pin out 1.

when i run my program·and use the·debug function, i see random pins showing a value of 1 when they should be 0. the pin numbers switch, the amount of pins showing in accurate values switch. its completely random. sometimes its just fine...and others it starts showing wrong values. the wrong values are even being shown in pin outs that don't have any leads going to them.

the code is basic.....it just displays if the pin is up or down so there is nothing funky going on there.

my question is:

how and why is it reading input values into the pin variables when no jumpers are connected to the pin outs?

thanks,
kevin
·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-11-30 06:56
    If I understand your quesiton correctly, what you're seeing is normal. If nothing is connected to a pin, and if the pin has not been declared as an output (i.e. if it's floating), reading that pin could result in a 0 or a 1, seemingly at random. To make sure a pin reads one or the other, it needs to be driven high or low — either internally by making it an output, or externally from the output of another circuit or a resistor to Vdd or Vss.

    -Phil
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-11-30 14:09
    Yup, another name for an "Input pin not connected to anything at all" is "antenna". Typically it picks up the 60 Hz 'noise' from your house-wiring or flourescent fixtures.

    The simple way to stop this is to tie the input pin to ground through a 10 Kohm resistor. This will cause the pin to report 'zero' when nothing is connected, but is easily overcome by real button-pushes (for instance).
Sign In or Register to comment.