Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: How do I use INPUT_PULLUP on pin 13 (LED)?

  1. #1
    Junior Member
    Join Date
    Feb 2019

    How do I use INPUT_PULLUP on pin 13 (LED)?

    Hi folks, do I need to treat pin 13 differently because it has an LED? Can I use the same INPUT_PULLUP? I wrote a little code to test some buttons I connected to the Teensy 3.2 just to verify that everything is connected correctly and 13 is behaving strangely. The serial monitor is often showing it pressed when it isnt. I did about 30 min of web searching to find an answer and I read you have to knock the LED off with a soldering iron. Is that really true? Thanks for your help.
    void setup() {                
      pinMode(0, INPUT_PULLUP);
      pinMode(1, INPUT_PULLUP);
      pinMode(2, INPUT_PULLUP);
      pinMode(3, INPUT_PULLUP);
      pinMode(4, INPUT_PULLUP);
      pinMode(5, INPUT_PULLUP);
      pinMode(6, INPUT_PULLUP);
      pinMode(7, INPUT_PULLUP);
      pinMode(8, INPUT_PULLUP);
      pinMode(9, INPUT_PULLUP);
      pinMode(10, INPUT_PULLUP);
      pinMode(11, INPUT_PULLUP);
      pinMode(12, INPUT_PULLUP);
      pinMode(13, INPUT_PULLUP);
      pinMode(14, INPUT_PULLUP);
      pinMode(15, INPUT_PULLUP);
      pinMode(16, INPUT_PULLUP);
      pinMode(17, INPUT_PULLUP);
      pinMode(18, INPUT_PULLUP);
      pinMode(19, INPUT_PULLUP);
      pinMode(20, INPUT_PULLUP);
      pinMode(21, INPUT_PULLUP);
      pinMode(22, INPUT_PULLUP);
      pinMode(23, INPUT_PULLUP); 
    void loop()                     
      if (digitalRead(0) == LOW) {
      if (digitalRead(1) == LOW) {
      if (digitalRead(2) == LOW) {
      if (digitalRead(3) == LOW) {
      if (digitalRead(4) == LOW) {
      if (digitalRead(5) == LOW) {
      if (digitalRead(6) == LOW) {
      if (digitalRead(7) == LOW) {
      if (digitalRead(8) == LOW) {
      if (digitalRead(9) == LOW) {
      if (digitalRead(10) == LOW) {
      if (digitalRead(11) == LOW) {
      if (digitalRead(12) == LOW) {
      if (digitalRead(13) == LOW) {
      if (digitalRead(14) == LOW) {
      if (digitalRead(15) == LOW) {
      if (digitalRead(16) == LOW) {
      if (digitalRead(17) == LOW) {
      if (digitalRead(18) == LOW) {
      if (digitalRead(19) == LOW) {
      if (digitalRead(20) == LOW) {
      if (digitalRead(21) == LOW) {
      if (digitalRead(22) == LOW) {
      if (digitalRead(23) == LOW) {

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    The LED acts as an external pull-down, which is much stronger than any internal pull-up, so it electrically overrides that. So yes, it is rather not possible to use pin13 in input pull-up mode without removing the LED.

    A workaround could be either not using pin13 in input pull-up mode (hasn’t the Teensy enough other pins you can use?) or using an external buffer like the 74lvc125 in conjunction with an external pull-up resistor at its input.

  3. #3
    Junior Member
    Join Date
    Feb 2019
    Hi Theremingenieur, thanks for your answer. Your responses are always appreciated. Im using all of the digital and analog inputs that are accessible through holes on the Teensy(as opposed to the ones that solder to the back of Teensy) except for DAC/A14. I can move the analog input from 23(A9) to DAC/A14 and move 13(LED) to 23. That'll work fine as long as DAC doesn't interfere with A14 in some way that I didn't anticipate like the LED interfering with 13. I'm going to look up info on DAC/A14 pin now and see what goes on there. Thanks!

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    The DAC is disabled on boot up, so it won't interfere by default and pin A14 will behave like any other analog input pin. Just take care to not accidentally activate the DAC, i.e. by having a analogWrite(A14) in your code.

    BTW: Pin A14 is a pure analog pin without any GPIO functionality and without 5V tolerance. Configuring it as input_pullup and doing digitalRead() won't work, so wiring an external pull-up resistor and then reading the 10bit analog value with analogRead() and an additional line of code to convert this into a simple hi/lo will be required.

    A simpler way might be maintaining pin13 and adding an external 470R resistor from that pin to +3.3V in order to reinforce the pull-up effect.

    How many digital input pins can one need? I'm curious to learn more about your project...

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts


    Or an alternative solution is to solder a wire to one of the pads underneath the Teensy 3.2.

    Another alternative solution is to move up to a Teensy 3.5 or 3.6 that gives you more pins brought out on the outer row.

    Alternatively consider moving some of the digital and analog pins to separate i2c/spi boards.
    • There are i2c boards that provide either digital input or output such as the MCP23017 that gives you 16 digital inputs or outputs.
    • There are separate boards like the ADS1015 that gives you 4 additional analog inputs.
    • You would typically want to use i2c for things like buttons and leds, where you don't need the fastest speed.
    • For things like PWM pins, there are other i2c boards, that provides PWM support for running servos, etc. (i.e. you tell the board how fast to cycle the pin, rather than having the Teensy do it).
    • To use i2c you would need to connect the 2 i2c pins (usually pins 18/A4 and 19/A5), plus a wire connecting the 3.3v power and ground pins to the i2c chips.
    • I2c can be chained together, as long as each i2c device has a separate address.
    • You might need pull-up resistors between each of the two i2c pins and 3.3v (usually 2.2k resistors are recomended).

    If you have a bare Teensy (or one with the pins soldered on, but you take off the plastic insulation), and you want to use the underneath pads, you can get various PCBs either pre-made or made to order by a PCB house like that give you access to the bottom pins when you solder it to the Teensy. Here are a few that I know about:

  6. #6
    Junior Member
    Join Date
    Feb 2019
    Thanks for the advice, guys. I moved a couple of pins around and its working great. Thank you for the recommendations for options that can give me more inputs. I had just enough inputs to get it working but in the future I'll try one of these ideas.

    My project is a tiny MIDI controller thats about wallet sized. There's just enough room in there for the 23 buttons, the 3 little pots, the wire and the teensy 3.2 and thats about it. It's working great. Thanks, guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts