Description
By using the pinMode() function, the pins of the Arduino can be configured into the following three modes:
- OUTPUT mode
- INPUT mode
- INPUT_PULLUP mode
In the input pull-up (INPUT_PULLUP) mode, the Arduino will enable the internal pull-up resistor of the pin to protect the circuit. Once the pin is set to input (INPUT) mode, the Arduino internal pull-up resistor will be disabled.
Set the Arduino pin to output (OUTPUT) mode
When the pin is set to output (OUTPUT) mode, the pin will be in a low resistance state, this means that Arduino can provide current to other circuit components, such as lighting up LEDs.
Set the Arduino pin to input (INPUT) mode
When the pin is set to input (INPUT) mode, the pin is in a high resistance state (100 MΩ). In this case, the pin can be used to read the potential signal of the sensor.
Set the Arduino pin to input pullup (INPUT_PULLUP) mode
The Arduino microcontroller comes with internal pull-up resistors. If you need to use this internal pull-up resistor, you can set the pin to input pull-up (INPUT_PULLUP) mode through pinMode().
Example codes
void setup() {
pinMode(13, OUTPUT); // sets the digital pin 13 as output
}void loop() {
…
}