Pin 13 as input

Hi:

I added a 10K resistor between Pin 13 and +5V, and set it as INPUT, as explained in the reference. But the pin will always read LOW!

I tried with a 4K7 resistor, it reads HIGH but as soon as I press the button, it will read LOW for ever. I tried with a 2K2 resistor, now it seems to work ok.

I'm afraid of frying the board!

What Arduino board is this?

^^ Not all Arduinos are made the same. If there is a LED directly connected to pin13, you can get this behaviour.

The LED/1k resistor pulls the pin low (~2volt LED forward voltage), when the pin is used as an input. Even with internal pull-up.

A ~1K resistor should pull the pin up reliably. No problem to go as low as 220ohm. Any lower could give problems if the pin is accidently used as an output.

Check if whatever has to switch the pin to ground can do so. 1k = 5mA. A common switch is not a problem. Leo..

rva1945: I added a 10K resistor between Pin 13 and +5V, and set it as INPUT, as explained in the reference. But the pin will always read LOW!

So you are not using a UNO.

rva1945: I tried with a 2K2 resistor, now it seems to work ok.

But the "L" indicator LED glows most of the time.

Easiest way out - use pin 13 as an output, and something else as input.

I'm sorry, I failed to say that I'm using the Nano.

Thanks for all the responses.

I didn’t know that I can use analog pins as digital inputs as well. Thus I will not run out of available digital inputs (I’m building a guitar effects pedalboard that will send MIDI CC commands through the serial port).

So I can leave pin 13 as an output and use its LED as an indicator of anything.

Thanks.

How do tell that I'm not using an UNO?

It has basically the same pins layout as of the Nano, that I'm using.

rva1945: How do tell that I'm not using an UNO?

By the behaviour of "pin 13".

The problem you described is due to the presence of a LED directly connected (by a resistor, 330 ohms on the original Nano) to pin 13, which pulls it down. To overcome this as a pull-up you have had to use a sufficiently low resistor. It does not have to be as low as the 330 ohm because the LED already has a voltage drop which is relatively close to the half-way threshold.

The UNO design deliberately avoids the problem with pin 13 by providing a high-impedance buffer to the LED - actually an op-amp. It is in fact, such a high impedance that if your code does not define pin 13 as an output and does not attach something to it to pull it down, the LED will light or go out quite randomly. This is never noticed initially, as the board comes with the "blink" program loaded, but it "spooks" people when they run another sketch which does not use pin 13.

So the fact that you had such a problem specifically demonstrates that you are using something other than a UNO. :grinning:

I'm having the same problem, I'm trying to use pin 13 as an input to a DHT11 temperature sensor and now I know that the led's resistor is driving the input low and I get no data from the sensor. The led turns on too (now I know that that L is for LED).

Other than using another input, was there another solution for this? I'd like to use input 13 as it's the only one on the top of the Arduino Nano chip, next to my sensor.

Thanks, Alex.