Difference between revisions of "PinMode()"
From Microduino Wiki
(Created page with "<pre style="color:green"> void pinMode (uint8_t pin, uint8_t mode) </pre> Set the mode of the pin<br> Configure the pin as input or output mode.<br> *'''Parameter''':<br> pi...") |
(No difference)
|
Latest revision as of 04:53, 12 August 2016
void pinMode (uint8_t pin, uint8_t mode)
Set the mode of the pin
Configure the pin as input or output mode.
- Parameter:
pin number of the pin
mode: INPUT, OUTPUT, or INPUT_PULLUP.
- Example:
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 }
- Note:
Analog pin can also be used as digital pin, and the numbers are 14 (corresponding to the analog pin 0) to 19 (corresponding to the analog pin 5).