Carthaginian
Member
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.
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");
}