pinMode__ - jimaobian/DFRobotWikiCn GitHub Wiki
void pinMode (uint8_t pin, uint8_t mode)
设置引脚模式
配置引脚为输出或输出模式.
参数:
- pin 引脚编号
- mode: INPUT, OUTPUT, 或 INPUT_PULLUP.
例子:
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
}
注解:
- 模拟引脚也可以当作数字引脚使用, 编号为14(对应模拟引脚0)到19(对应模拟引脚5).