Hello,
For the past two hours I've been getting mad with a very basic stuff which behaves oddly, I hope somebody here would be able to help me :
I'm using a Teensy 4.1 and I have weird interferences while trying to use a simple button on an input pin. The pushbutton is connected to pin 34 on one side and to ground on the other side.
Pin 34 is configured as INPUT_PULLUP. However, when the button is not pressed (= pin 34 left in air), I get random HIGH and LOW readings in the sketch.
If I remove the wires going off the Teensy to the button, it is stable HIGH, but it seems that as soon as I put a wire about 5cm long connected to pin 34 and leave open the other side, I get random readings specially when my hand comes close to the wire as if the system was extra sensitive to magnetic fields. But I guess the internal PULLUP resistor should be far stronger than this and keep the pin HIGH.
I tried to use a different power supply to make sure it was not causing parasites, no success. I tried other input pins, no success. I tried also with another Teensy 4.1, no success either.
Software is teensyduino 1.53 with arduino 1.8.13
I don't have this issue with other boards (Mega, Teensy LC...).
Anyone has a clue ?
Below is my test sketch :
when I have interferences, a lot of lines flow in the serial monitor.
For the past two hours I've been getting mad with a very basic stuff which behaves oddly, I hope somebody here would be able to help me :
I'm using a Teensy 4.1 and I have weird interferences while trying to use a simple button on an input pin. The pushbutton is connected to pin 34 on one side and to ground on the other side.
Pin 34 is configured as INPUT_PULLUP. However, when the button is not pressed (= pin 34 left in air), I get random HIGH and LOW readings in the sketch.
If I remove the wires going off the Teensy to the button, it is stable HIGH, but it seems that as soon as I put a wire about 5cm long connected to pin 34 and leave open the other side, I get random readings specially when my hand comes close to the wire as if the system was extra sensitive to magnetic fields. But I guess the internal PULLUP resistor should be far stronger than this and keep the pin HIGH.
I tried to use a different power supply to make sure it was not causing parasites, no success. I tried other input pins, no success. I tried also with another Teensy 4.1, no success either.
Software is teensyduino 1.53 with arduino 1.8.13
I don't have this issue with other boards (Mega, Teensy LC...).
Anyone has a clue ?
Below is my test sketch :
Code:
int state = 0;
void setup() {
// put your setup code here, to run once:
pinMode(34, INPUT_PULLUP);
Serial.begin(9600);
delay(1000); // let the serial stuff to boot, useful on Teensy
Serial.println("--- Hello ---"); // just to see that the sketch boots
}
void loop() {
if (digitalRead(34) != state){
state = digitalRead(34);
Serial.print("new state : ");
Serial.println(state);
}
}
when I have interferences, a lot of lines flow in the serial monitor.