DigitalWrite()
來(lái)自ALSROBOT WiKi
void digitalWrite (uint8_t pin, uint8_t value)
寫(xiě)數(shù)字引腳
寫(xiě)數(shù)字引腳, 對(duì)應(yīng)引腳的高低電平. 在寫(xiě)引腳之前, 需要將引腳設(shè)置為OUTPUT模式.
參數(shù):
- pin 引腳編號(hào)
- value HIGH 或 LOW
用法:
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); // 點(diǎn)亮LED delay(1000); // 等待1秒 digitalWrite(ledPin, LOW); // 關(guān) delay(1000); // waits for a second }
注解:
- 模擬引腳也可以當(dāng)作數(shù)字引腳使用, 編號(hào)為14(對(duì)應(yīng)模擬引腳0)到19(對(duì)應(yīng)模擬引腳5).