舵机反转,怎么写啊
如题,官方的教程都是0-180或者180-0转,我想知道反过来该如何该这程序// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
#include <Servo.h>
Servo myservo;// create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9);// attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 90; pos += 1)// goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
}
} 你这上半部分是正转,下半部分是反转。还能怎么转?
难道下面这样?一开始就是180度?
int pos = 180;
myservo.write(pos);
for(pos = 180; pos > 0 ; pos -= 1)
{
myservo.write(pos);
} 麽麽茶㊣ 发表于 2012-10-10 13:57 static/image/common/back.gif
你这上半部分是正转,下半部分是反转。还能怎么转?
难道下面这样?一开始就是180度?
int pos = 180;
还在研究,舵机上装了机械手,舵机控制起来不是太好
页:
[1]