原帖由
A670521546
发自:dev.eefocus.com
------------------------------------------------------------------------------------------------------------------------------------------
都这么长时间了。开始学习起来,不要再空着板子了,不然板子会寂寞的
先从最简单的流水灯来吧
代码这个很简单: void setup() {
// initialize the digital pin as an output.
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
while(1){
digitalWrite(5, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(5, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(6, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(6, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(7, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(7, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(8, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(8, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(9, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(9, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(10, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(10, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(11, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(11, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(12, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(12, LOW); // set the LED off
delay(1000); // wait for a second
}
}
|