设为首页收藏本站

arduino 单片机机器人爱好者之家

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 723|回复: 4

4轴飞行器I

[复制链接]

签到天数: 27 天

[LV.4]偶尔看看III

发表于 2016-4-10 12:54:50 | 显示全部楼层 |阅读模式
本帖最后由 hero_sun 于 2016-4-10 18:56 编辑

决定做一个飞行器,淘宝买的东西还没到,程序:
[AppleScript] 纯文本查看 复制代码
const int dj1=A0,dj2=A1,dj3=A2,dj4=A3;
int readpin=9;
void setup() 
{
  pinMode(readpin,INPUT);
}

void loop() 
{
  int analogread=analogRead(readpin);
  if(analogread=1)
  {
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,100);
    analogWrite(dj4,100);
  }
 if(analogread=2)
  {
    analogWrite(dj1,50);
    analogWrite(dj2,50);
    analogWrite(dj3,100);
    analogWrite(dj4,100);
  delay(1000);
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,100);
    analogWrite(dj4,100);}
 if(analogread=3)
  {
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,50);
    analogWrite(dj4,50);
  delay(1000);
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,100);
    analogWrite(dj4,100);
  }
 if(analogread=4)
  {
    analogWrite(dj1,30);
    analogWrite(dj2,30);
    analogWrite(dj3,30);
    analogWrite(dj4,30);
  }
 if(analogread=5)
  {
    analogWrite(dj1,30);
    analogWrite(dj2,30);
    analogWrite(dj3,100);
    analogWrite(dj4,100);
  delay(1000);
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,100);
    analogWrite(dj4,100);
   }
  
   if(analogread=5)
  {
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,30);
    analogWrite(dj4,30);
  delay(1000);
    analogWrite(dj1,100);
    analogWrite(dj2,100);
    analogWrite(dj3,100);
    analogWrite(dj4,100);
   }
  
  
  }








}






如有更好的方案请回帖,如有成果也请回帖!

签到天数: 1 天

[LV.1]初来乍到

发表于 2016-5-7 13:56:16 | 显示全部楼层

回帖奖励 +2

加油   哈哈

点评

加油  发表于 2016-5-8 09:00
回复 支持 1 反对 0

使用道具 举报

签到天数: 1 天

[LV.1]初来乍到

发表于 2016-4-10 17:31:33 | 显示全部楼层
谢谢,我最近也在做这个东西,给我上了一课。
回复 支持 反对

使用道具 举报

签到天数: 27 天

[LV.4]偶尔看看III

 楼主| 发表于 2016-5-29 07:55:58 | 显示全部楼层
小飞系统好了!

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|联系我们|YFRobot ( 苏ICP备13017135  

GMT+8, 2017-11-20 17:19 , Processed in 0.181817 second(s), 25 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表