我们先来回顾一下上节课的内容:
word | meaning |
---|---|
motor | 马达 |
direct current | 直流电 |
我们来看一下今天的作业单吧:
作业单 |
---|
用四个按钮,让风扇可以调换风速,分别是0-3档 |
void setup (){
//初始化程序
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
}
void loop(){
//大循环
if (digitalWrite(13) == 0){
analogRead(6,0);
}else if (digitalWrite(12) == 0){
analogRead(6,100);
}else if (digitalWrite(11) == 0){
analogRead(6,200);
}else if (digitalWrite(10) == 0){
analogRead(6,255);
}
}
THANK YOU VERY MUCH !
网友评论