资源描述:
《arduino应用范例例》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Arduino应用范例10例作者:小新哥13/13目录1.趣味彩灯.................................................................................32.楼道延时报警灯.....................................................................43.行程自动往返工件传送带.....................................................54.A、B、C三路智能抢答器.............
2、.......................................65.机床控制系统.........................................................................76.楼上楼下共控一灯.................................................................87.工厂顺序启动反顺序停车控制系统.....................................98.楼道声光控灯...........................
3、.............................................109.水塔自动上水装置................................................................1110.电机拖动控制......................................................................1213/131.趣味彩灯voidsetup(){for(inti=0;i<=7;i++)//把0-7设置为输入pinMode(i,INPUT);for(intj=8;j<
4、=13;j++)//把8-13设置为输出pinMode(j,OUTPUT);}voidloop(){if(digitalRead(1)==HIGH){if(digitalRead(1)==HIGH){for(intx=9;x<=12;x++)//循环方式依次让每个led在1秒内点亮{digitalWrite(x,HIGH);delay(1000);}}delay(10000);for(intx=9;x<=12;x++)//循环方式依次让每个led熄灭{digitalWrite(x,LOW);}for(intK=1;K<=10;K++)//循环10次,亮0.5秒灭0.5秒
5、,共10秒13/13{digitalWrite(13,HIGH);delay(500);digitalWrite(13,LOW);delay(500);}}}2.楼道延时报警灯voidsetup(){for(inti=0,j=9;i<=8,j<=13;i++,j++)//设置0-8为输入,9-13为输出{pinMode(i,INPUT);pinMode(j,OUTPUT);}}voidloop(){if(digitalRead(1)==HIGH
6、
7、digitalRead(2)==HIGH)//引脚1或2置高电平{digitalWrite(9,HIGH);//9置高电平d
8、elay(25000);//延时25秒digitalWrite(10,HIGH);//10置高电平delay(5000);//延时5秒digitalWrite(10,LOW);//10置低电平digitalWrite(9,LOW);//9置低电平}}13/132.行程自动往返工件传送带voidsetup(){for(inti=0;i<=7;i++)//把0-7设置为输入pinMode(i,INPUT);for(intj=8;j<=13;j++)//把8-13设置为输出pinMode(j,OUTPUT);}voidloop(){if(digitalRead(1)==HIG
9、H){digitalWrite(9,HIGH);digitalWrite(10,LOW);}if(digitalRead(2)==HIGH){digitalWrite(10,HIGH);digitalWrite(9,LOW);}if(digitalRead(3)==HIGH){digitalWrite(9,LOW);digitalWrite(10,LOW);}}13/132.A、B、C三路智能抢答器(直接用带闪烁灯的蜂鸣器更好)voidsetup(){for(inti=0,j=9;i<=8,j<=13;i++,j++)//设置0-8为输入