Set the mode of an individual pin.
Pins on the board can be used for either digital output, digital input, or analog input. Setting the pin mode of a pin determines how it will be used in the program.
Set the pin of the red LED to output and turn it on.
// Red LED is connected to pin 13 pinMode(13, "output"); // Turn pin 13 to on (1) digitalWrite(13, 1);
pinMode(pin, mode);
Name | Type | Required? | Description |
---|---|---|---|
pin | Number | The number of the pin you want to change. This is usually printed on your board, but can also be found in your board's documentation. | |
mode | String | The mode that this pin will be set to. Must be one of * "input" * "output" * "analog" |
Found a bug in the documentation? Let us know at documentation@code.org