Skip to main content

Can D13 pin of Arduino Uno and nano be use as input pin?


  • D13 pin can be use as digital output pin.
  • D13 pin can be use as input pin together with external pull-up and pull-down resistor.
  • It is not recommand to use the D13 internal pull-up resistor because instead of the regular 5V, the voltage will be hanging around 1.7V.

Most of Arduino newbies have their first code to blink the LED with D13 pin as an output pin. This really give us big confident to know the code can be successfully executed on the microcontroller. However, due to the build-in D13 pin on different Arduino board has slightly different circuit design, is there any limitation to use the D13 GPIO pin as input pin? Let’s find out more!

Experiment condition

I investigate both the value of D13 digital input and LED light status with the following code with Arduino Uno Rev3. and Arduino nano 3.0. 
void setup() {
  pinMode(13, INPUT);
  Serial.begin(9600);
}
void loop() {
  Serial.println(digitalRead(13));
}
I will illustrate the result from the view point of both the circuit diagram and the experiment result.

D13 pin on Arduino Uno - Can be use as input 

From the Schematic below, UNO Rev3 use an opamp between D13(SCK) and LED pin. Hence, there is no problem using D13 as an input pin. Interestedly  from the experiment result, when we use D13 as input, the LED will be ON under the condition when there isn’t any wire connect to the D13 pin.
The D13 pins works fine on UNO to be use as digital input pin, The LED has been light on when connect to 5V and dimmed when connected to GND.

D13 pin as input on Arduino nano

From the schematic of nano below, the D13 pin connect to both the LED and PB5.
Under the testing condition, the digital input from D13 pin has no problem. Differnet from the UNO board, the LED will be OFF when there is no wire connect to D13 pin, Of course, the LED will be on when D13 connect to 5V and be OFF when connect to GND. However, because the voltage will be divided and the LED still consume some power,under some circumstance, I am not sure if there will be some problem using D13 on nano as input.

Internal pull-up is not recommend to be use at D13

When you initiate the internal pull-up at D13, the onboard LED connect to D13 will pull the voltage down, hence the voltage will be hanging around around 1.7V instead of the regular 5V at other GPIO pin. Therefore, it is not recommend to us D13 internal-pull up.



Conclusion

From my experiment, there’s no big problem to use D13 as input on both UNO and nano with HIGH input voltage (5vor 3.3V) and LOW voltage.. Here is the result I’ve been obtain from the experiment.

LED status

UNO
nano
No connection
light ON, Serial print unstable
light OFF, Serial print unstable
Connect to 5V
light ON, Serial print 1
light ON, Serial print 1
Connect to GND
light OFF, Serial print 0
light OFF, Serial print 0
Generally speaking, it is not a perfect idea to use D13 pin as an input pin on Arduino.
However, from this simple test, the D13 pin can works pretty fine as an input on both UNO and nano. The external pull-up and pull-down can simply solve the unstable fluctuating when there is no connection.
I am just not sure if there is some condition it cannot execute as what we want. There is just little difference under the condition when we set the pin mode of D13 to input without any wire connect to it.

Further reading:

Comments

Popular posts from this blog

Arduino CNC shield control Stepper motor with DRV8825

CNC shield is quite useful for stepper motor driving. Here, I demonstrated how to use simple arduino code to drive stepper motor with DRV8825. First, just simply mount CNC shield onto Arduino Uno. Make sure the direction of the shield was right, where both the USB port and power supply wire was on your left hand site. The blue wire is my power supply which can be connect to 12-36V of power source. Next step you can mount the DRV8825 chip onto the CNC shield. Make sure the DRV8825 chip goes like this direction. If you put the chip in the wrong direction, you will probably damage it. By adjusting the jumber underneath the DRV8825 chip, motors can be driven with different kind of microstepping mode. I put three number here so it means that I set it into 1/32 step driving mode. Which is the most precise  one of DRV8825. The motor can connect to the right site of the DRV8825. Plug in the usb to your computer and upload these coded which will generate ste

Connect Arduino Wemos D1 ESP8266 to Internet/Wi-Fi Router

Connect ESP8266 to Wi-Fi Router Upload these code to your Arduino WeMos D1 ESP8266 W-Fi board. #include <ESP8266WiFi.h> //SSID of your network char ssid[] = " myRouter"; //SSID of your Wi-Fi router char pass[] = " myPassWord"; //Password of your Wi-Fi router void setup() {   Serial.begin(115200);   delay(10);   // Connect to Wi-Fi network   Serial.println();   Serial.println();   Serial.print("Connecting to...");   Serial.println(ssid);   WiFi.begin(ssid, pass);   while ( WiFi.status() != WL_CONNECTED) {     delay(500);     Serial.print(".");   }   Serial.println("");   Serial.println("Wi-Fi connected successfully"); } void loop ( ) {} Using ESP8266 to connect to Wi-Fi need to use the function of: WiFi.begin(ssid, pass); // connect to target Wi-Fi SSID is the name of the Wi-Fi you want to connect to.  while ( WiFi.status() != WL_CONN

Setting up CUDA 10.0 for mxnet on Google Colaboratory

Preface Recently, I was trying to train model on Google Colaboratory with mxnet. However, I found the CUDA version pre-installed on the Colab. is 10.2. Till now, mxnet only support to CUDA 10.1 Therefore, I started to think about if it is possible to setup the environment that mxnet has support. Till now CUDA 10.1 doesn’t work for me. But I do successfully installed CUDA 10.0. Also tried to trained a LeNet on Colaboratory. Since I am a mac user, NVIDIA GPU is always what we are jealous and envy. Until I found Google Colaboratory…. I’d like to share my journey with you, if you also encounter some problem on setting up environment. Google Colaboratory provide free access to the NVIDIA Tesla K80 GPU (24GB RAM, 4992 CUDA core) . It is a great gift for most of people who is eager to learn deep learning but doesn’t have good hardware systems to train deeper models. NVIDIA Tesla K80 GPU I assume that you already have background knowledge of Python and familiar with tools like jup