- 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
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
Post a Comment