不多说上代码:
/* 本文重点在于掌握两个函数pinMode和digitalWrite*/
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT); //引脚设置2,3,4,5,6,7;
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for(int i=2; i <= 7; i++){ // 用for循环依次调用每一个I/o口
digitalWrite(i, HIGH);
delay(200);
digitalWrite(i, LOW);
delay(200);
}
}
效果图