arduino uno只能同时驱动2个舵机吗?
本帖最后由 咱家宝的大胖熊 于 2012-4-22 15:42 编辑使用arduono sensor shield v5.0连接6个mg995舵机。分别接在0~5引脚。
简单的改写sweep程序,让6个舵机同时摆动。可问题是
只有0,4会摆动。其他不动,请问是在呢么回事?
http://t2.baidu.com/it/u=3746729786,2942263212&fm=51&gp=0.jpg#include <Servo.h>
Servo myservo0;// create servo object to control a servo
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int pos = 0; // variable to store the servo position
void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object
myservo1.attach(1);
myservo1.attach(2);
myservo1.attach(3);
myservo1.attach(4);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1)// goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo0.write(pos); // tell servo to go to position in variable 'pos'
myservo1.write(pos);
myservo2.write(pos);
myservo3.write(pos);
myservo4.write(pos);
myservo5.write(pos);
delay(10); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo0.write(pos); // tell servo to go to position in variable 'pos'
myservo1.write(pos);
myservo2.write(pos);
myservo3.write(pos);
myservo4.write(pos);
myservo5.write(pos);
delay(10); // waits 15ms for the servo to reach the position
}
} void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object
myservo1.attach(1);
myservo1.attach(2);
myservo1.attach(3);
myservo1.attach(4);
}
初始化有误 i7456 发表于 2012-4-22 17:09 static/image/common/back.gif
void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object
呵呵,却是是这里有问题。我重新试验了6个舵机洗刷刷,ok了,感谢。 问一下,我是菜鸟,现在市面上所有的舵机控制板都兼容Arduino吗? 咱家宝的大胖熊 发表于 2012-4-22 18:31 static/image/common/back.gif
呵呵,却是是这里有问题。我重新试验了6个舵机洗刷刷,ok了,感谢。
是什么问题啊 小美 发表于 2013-1-31 10:06 static/image/common/back.gif
是什么问题啊
void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object
myservo1.attach(1);
myservo1.attach(2);
myservo1.attach(3);
myservo1.attach(4);
}
改为
void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object
myservo1.attach(1);
myservo2.attach(2);
myservo3.attach(3);
myservo4.attach(4);
} smfox10 发表于 2013-1-31 11:33 static/image/common/back.gif
void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object...
哦哦哦~谢谢~我看出来了 嘿嘿 smfox10 发表于 2013-1-31 11:33 static/image/common/back.gif
void setup()
{
myservo0.attach(0);// attaches the servo on pin 9 to the servo object...
之前我二了 嘿嘿 居然没看出来 小美 发表于 2013-2-1 13:53 static/image/common/back.gif
之前我二了 嘿嘿 居然没看出来
其实很正常,当运行结果和你的理想不符合的时候就看看代码。很多时候都是粗心大意照成的。 好东西,学习一下!!!! 亲,能否跟我讲一下电路怎么接,我是要做四轴飞行器的,谢谢 本质上库就是用软件模拟的,你拿2560来,每个IO接一个舵机都可以 可是还不好使呀
不用shield板也可以驱动6个的 只不过需要另外给舵机单独供电 impking 发表于 2016-8-28 00:40
不用shield板也可以驱动6个的 只不过需要另外给舵机单独供电
我用arduino控制六个舵机,都能单独正常工作,在一起工作会出现一些莫名其妙的动作
页:
[1]