Hide minor edits - Show changes to markup
As of Arduino 1.0.1, it is possible to use the internal pullup resistors with the mode INPUT_PULLUP.
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.
mode: INPUT, OUTPUT, or INPUT_PULLUP.
mode: INPUT, OUTPUT, or INPUT_PULLUP. (see the digital pins page for a more complete description of the functionality.)
Configures the specified pin to behave either as an input or an output. See the description of digital pins for details.
Configures the specified pin to behave either as an input or an output. See the description of digital pins for details on the functionality of the pins.
As of Arduino 1.0.1, it is possible to use the internal pullup resistors with the mode INPUT_PULLUP.
[@
(:source lang=arduino tabwidth=4:)
@]
(:sourceend:)
mode: INPUT, OUTPUT, or INPUT_PULLUP.
The analog input pins can be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5).
The analog input pins can be used as digital pins, referred to as A0, A1, etc.
pinMode(pin, mode)
Configures the specified pin to behave either as an input or an output. See the reference page below.
Configures the specified pin to behave either as an input or an output. See the description of digital pins for details.
The analog input pins can be used as digital pins w/ numbers 14 (analog input 0) to 19 (analog input 5).
The analog input pins can be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5).
valid pin numbers on most boards are 0 to 19, valid pin numbers on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite and pinMode commands.
The analog input pins can be used as digital pins w/ numbers 14 (analog input 0) to 19 (analog input 5).
Configures the specified pin to behave either as an input or an output.
Configures the specified pin to behave either as an input or an output. See the reference page below.
pin: the number of the pin whose mode you want to set. (int)
pin: the number of the pin whose mode you wish to set. (int)
valid pin numbers on most boards are 0 to 19, valid pin numbers on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite and pinMode commands.
Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.
Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.
There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.
pinMode(pin, INPUT); // set pin to input digitalWrite(pin, HIGH); // turn on pullup resistors
Note that the pullup resistors provide enough current to dimmly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimmly, this is likely what is going on, and you have forgotten to use pinMode to change the pins to outputs.
Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors.
Note that the pullup resistors provide enough current to dimmly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimmly, this is likely what is going on, and you have forgotten to use pinMode to change the pins to outputs.
Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor(resistor to ground) to the input, with 10K being a common value.
Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.
Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can sorce (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.
Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.
Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown (resistor to ground) resistor to the input, with 10K being a common value.
Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor(resistor to ground) to the input, with 10K being a common value.
Pins configured as outputs with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can sorce (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect output pins with 470Ω or 1k resistors.
Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can sorce (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect output pins with 470Ω or 1k resistors.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.
Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.
Pins configured as outputs with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can sorce (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids or motors.
Pins configured as outputs with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can sorce (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.
Pins configured as outputs with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can provide up to 40 mA (milliamps) to other devices. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids or motors.
Pins configured as outputs with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can sorce (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids or motors.
Often it is useful however to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC) or pulldown (resistor to ground) resistor to the input, with 10K being a common value.
Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown (resistor to ground) resistor to the input, with 10K being a common value.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a touch sensor.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs have an extremely high input impedance (~100 Megohm). This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a touch sensor.
Often it is useful however to steer an input pin to a known state, if no input is present. This can be done by adding a pullup (resistor to VCC) or pulldown (resistor to ground) resistor to the input, with 10K being a common value.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a touch sensor.
Often it is useful however to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC) or pulldown (resistor to ground) resistor to the input, with 10K being a common value.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, either/or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately.
pinMode (pin, INPUT); // set pin to input digitalWrite (pin, HIGH); // turn on pullup resistors
pinMode(pin, INPUT); // set pin to input digitalWrite(pin, HIGH); // turn on pullup resistors
Pins configured as outputs with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can provide up to 40 mA (milliamps) to other devices. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids or motors.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, either/or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs have an extremely high input impedance (~100 Megohm). This means that it takes very little current to move the input pin from one state to another and can make the pins useful for such tasks as capacitive sensing.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs have an extremely high input impedance (~100 Megohm). This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a touch sensor.
[@
[@
configures pin number 13 to work as an output pin.
Arduino (Atmega) pins default to inputs, so don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs have an extremely high input impedance (~100 Megohm). This means that it takes very little current to move the input pin from one state to another and can make the pins useful for such tasks as capacitive sensing.
Often it is useful however to steer an input pin to a known state, if no input is present. This can be done by adding a pullup (resistor to VCC) or pulldown (resistor to ground) resistor to the input, with 10K being a common value.
There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.
pinMode (pin, INPUT); // set pin to input digitalWrite (pin, HIGH); // turn on pullup resistors
pinMode(int pin, int mode)
you need to specify the number of the pin you want to configure followed by the word INPUT or OUTPUT.
nothing
pinMode(int pin, int mode)
pinMode(ledPin, OUTPUT); // sets the digital pin as output
[@
@]
pinMode(ledPin, OUTPUT); // sets the digital pin as output
you need to specify the number of the pin y ou want to configure followed by the word INPUT or OUTPUT.
Configures the specified pin to behave like an input or an output.
Configures the specified pin to behave either as an input or an output.
ou want to configure followed by the word INPUT or OUTPUT.
[@int ledPin = 13; // LED connected to digital pin 13
[@
int ledPin = 13; // LED connected to digital pin 13
int ledPin = 13; // LED connected to digital pin 13
[@int ledPin = 13; // LED connected to digital pin 13
}
} @]
@@int ledPin = 13; // LED connected to digital pin 13
int ledPin = 13; // LED connected to digital pin 13
}@@
}
[@int ledPin = 13; // LED connected to digital pin 13
@@int ledPin = 13; // LED connected to digital pin 13
}@]
}@@
[@
int ledPin = 13; // LED connected to digital pin 13
[@int ledPin = 13; // LED connected to digital pin 13
} @]
}@]
Configures the speficied pin to behave like an input or an output.
Configures the specified pin to behave like an input or an output.
[=
[@
=]
@]
@@int ledPin = 13; // LED connected to digital pin 13
[= int ledPin = 13; // LED connected to digital pin 13
}@@
} =]
[@int ledPin = 13; // LED connected to digital pin 13
@@int ledPin = 13; // LED connected to digital pin 13
}@]
}@@
[@ int ledPin = 13; // LED connected to digital pin 13
[@int ledPin = 13; // LED connected to digital pin 13
}
@]
}@]
pinMode(13,OUTPUT)
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
Configures the speficied pin to behave like an input or an output.
you need to specify the number of the pin y ou want to configure followed by the word INPUT or OUTPUT.
nothing
pinMode(13,OUTPUT)
configures pin number 13 to work as an output pin.