先写在这里,还没经过测试。

1. LED两端往中间移动,到中间后向两边返回。

 // adr301.ino

 byte ledPin[] = {, , , , , , , , , };
int ledDelay();
int direction = ;
int currentLED = ;
unsigned long changeTime; void setup() {
for(int i=; i<; i++){
pinMode(ledPin[i], OUTPUT);
} changeTime = millis();
} void loop() {
if((millis() - changeTime) > ledDelay){
changeLED();
changeTime = millis();
}
} void changeLED() {
for(int i=; i<; i++){
digitalWrite(ledPin[i], LOW);
} digitalWrite(ledPin[currentLED], HIGH);
digitalWrite(ledPin[ - - currentLED], HIGH); currentLED += direction; if(currentLED == ){
direction = -;
} if(currentLED == ){
direction = ;
}
}

添加结果视频

2. LED弹跳球

 // adr302.ino

 byte ledPin[] = {, , , , , , , , , };
int ledDelay();
int direction = ;
int currentLED = ;
int maxHeight = ;
unsigned long changeTime; void setup() {
for(int i=; i<; i++){
pinMode(ledPin[i], OUTPUT);
} changeTime = millis();
} void loop() {
if((millis() - changeTime) > ledDelay){
changeLED();
changeTime = millis();
}
} void changeLED() {
for(int i=; i<; i++){
digitalWrite(ledPin[i], LOW);
} digitalWrite(ledPin[currentLED], HIGH); currentLED += direction; if(currentLED == maxHeight){
direction = -;
maxHeight -= ;
} if(currentLED == ){
direction = ;
maxHeight = ;
}
}

最新文章

  1. 帝国cms 页面统计
  2. MVC &ndash; 3.EF(Entity Framework)
  3. Using AFNetWorking 2.0 upload file to php web service server based on Slim
  4. 命令行启动win7系统操作部分功能
  5. Rails: No such file or directory - getcwd
  6. Linux常用命令_(网络管理)
  7. HDU 3255 扫描线(立方体体积并变形)
  8. 360云盘、百度云、微云……为什么不出 OS X(Mac 端)应用呢?(用户少,开发成本高)(百度网盘Mac版2016.10.18横空出世)
  9. 关于css浮动的一些总结
  10. 也谈谈关于WEB的感想
  11. C++编程技术之 异常处理(上)
  12. erlang link 与 monitor
  13. swust oj 1068
  14. create-react-app脚手架中配置webpack的方法
  15. LeetCode 88. 合并两个有序数组
  16. css3自定义placeholder字体颜色
  17. 外网不能访问阿里云服务器的apache服务
  18. jQery的方法
  19. 日志_测试代码_Delphi7
  20. Android-应用安装/替换/卸载/广播监听

热门文章

  1. 怎样在win7下装ubuntu(硬盘版安装)
  2. Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
  3. android83 Activity的生命周期,启动模式,返回时传递数据
  4. Linux命令之ssh
  5. android开发之记录ListView滚动位置
  6. Android开发之意图解析
  7. awk用法举例
  8. JSTL时间比较,jstl日期比较,jsp比较时间
  9. 20、CSS
  10. ssh 无密码登录远程服务器