Digital pins seem to respond to human touch.

Status
Not open for further replies.
I have been getting very inconsistent, glitchy output from my teensy and breadboard setup. My intention was that a button/combination of buttons would result in a certain message to the console. However, the message would chatter unpredictably. For the longest time I thought there was a problem with my breadboard. However, I have traced the problem right back to the board itself.

Here's the ungodly simple setup: There is a 22g wire touching the board at Pin 9.

Now, when my right hand is not touching the wire, I get the message "pin 2 is not pressed".
When I am touching, I get "pin 2 pressed"...frequently but not continuously.

The I/O pin seems to like me.

What are the electrical reasons why this happens? Is this just a fact I have to deal with? It seems I can't even assemble a simple digital I/O circuit without getting these kinds of problems. Perhaps the pull-up resistor system is more reliable (I don't know), but I'm working on a Midi project and would rather not have the extra lag that pull-up resistors cause.

Code:
const int in_1 = 12;

void setup()
{
  Serial.begin(38400);
  pinMode(in_2, INPUT); // Pushbutton
}

void loop()
{
  if(digitalRead(in_2)) {
    Serial.println("pin 2 pressed");
  } else {
    Serial.println("pin 2 not pressed");
  }
 
Perhaps the pull-up resistor system is more reliable (I don't know),

Yes, you need pullup resistors, and the buttons wired between the pin and ground.

but I'm working on a Midi project and would rather not have the extra lag that pull-up resistors cause.

This is a non-issue. A 50k pullup and 50 pF capacitance on the button + wires responds in approx 2.5 us.

To keep such a short time in perspective, consider the speed of sound (through air at sea level) is approx 340 meters/second. During the 2.5 us time that pullup resistor takes to allow the line to return high, sound can only travel only 0.85 mm. Such a short time is of no consequence in any musical or human response application.

USB host controllers schedule bandwidth on 1 ms frames. Anything you transmit may potentially wait until the next USB frame before the host controller allows the packet to transfer over the USB cable.

Most pushbuttons have mechanical chatter in the scale of 1 to 10 ms. If you don't properly debounce (eg, using the Bounce library), you risk detecting multiple events.

Human perception of "instantaneous" is at best in the 10 to 50 ms range, and often about 100 ms.

Human hearing perceives multiple sounds delayed less than 20 ms as part of the same sonic event.

2.5 us, or 0.0025 ms, is an incredibly short time. But if you're really worried about it anyway, just use a physical 1K pullup resistor instead of the on-chip pullup. A 1K resistor will respond 50X faster, which has no practical benefit in this application.
 
Status
Not open for further replies.
Back
Top