Pin 13 on Teensy 3.2 wont work for switch

Status
Not open for further replies.
Hi Im using a Teensy 3.2 as a USB game controller but for some reason PIN 13 seems to not work correctly. Is this because of the LED function? Is there a way around this?
 
Is "not work correctly" :: 'intermittent', slow or not at all?

Is the pin wired Pull UP or DOWN? Internally or externally?
 
Is this because of the LED function?

Yes. Or probably yes, given that we can't see your wiring or your code, but this is a common problem when pushbuttons are used in the ordinary way.

Is there a way around this?

Connect the pushbutton between 3.3V and pin 13, and a resistor from pin 13 to GND. Or try pinMode INPUT_PULLDOWN instead of a real resistor.

Or use another pin.
 
Yes. Or probably yes, given that we can't see your wiring or your code, but this is a common problem when pushbuttons are used in the ordinary way.



Connect the pushbutton between 3.3V and pin 13, and a resistor from pin 13 to GND. Or try pinMode INPUT_PULLDOWN instead of a real resistor.

Or use another pin.

All other switches are wired identically and working with the Arduino code setting pinMode to input_pullup.

I did notice that when I grounded pin 13 to myself the switch seemed to work although the LED would go on and off. Not that I care if the led goes on and off but I wasnt sure if that would cause any issues elsewhere.

IMG_20190904_042743.jpg
 
All other switches are wired identically and working with the Arduino code setting pinMode to input_pullup.

I did notice that when I grounded pin 13 to myself the switch seemed to work although the LED would go on and off. Not that I care if the led goes on and off but I wasnt sure if that would cause any issues elsewhere.
The issue is that since pin 13 has a LED attached to it, the LED includes a resistor, and that changes the electrical characteristics of the line when trying to read from it. Hence Paul's suggestions of ways to work around that resistor. IIRC, using INPUT_PULLDOWN (or the resistor) will also flip the result of digitalRead.
 
You can then take the inverse of the flip afterwards !digitalRead

keep a little //comment there if you do this so you understand why later on when working on your project :)
 
Status
Not open for further replies.
Back
Top