Forum >Servo conection for my DFRduino Romeo-All in one Controller
Servo conection for my DFRduino Romeo-All in one Controller

[quote]
Hello,
I bought the Romeo Boards v1.1 and v2 some time ago.
How can i connect 4 servos to the two models.
my search was unsuccessful in the wiki.
Thank you!
Greeting
[/quote]
2013-08-06 22:25:26 Hi ,
it is very simple,
you can connect 4 servo to the model
and try this code .
You can change the date which you need.
[code]
#include <Servo.h>
Servo Aservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
Servo Bservo;
Servo Cservo;
Servo Dservo;
int posA = 0; // variable to store the servo position
int posB = 0;
int posC = 0;
int posD = 0;
void setup()
{
Aservo.attach(2); // attaches the servo on pin 2 to the servo object
Bservo.attach(3); // attaches the servo on pin 3 to the servo object
Cservo.attach(9); // attaches the servo on pin 9 to the servo object
Dservo.attach(11); // attaches the servo on pin 11 to the servo object
}
void loop()
{
for(posA = 0,posB = 0,posC = 0,posD = 0; posA < 180,posB < 180,posC < 180,posD < 180; posA += 1,posB += 1,posC += 1,posD += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
Aservo.write(posA); // tell servo to go to position in variable 'posA'
Bservo.write(posB); // tell servo to go to position in variable 'posB'
Cservo.write(posC); // tell servo to go to position in variable 'posC'
Dservo.write(posD); // tell servo to go to position in variable 'posD'
delay(15); // waits 15ms for the servo to reach the position
}
for(posA = 180,posB = 180,posC = 180,posD = 180; posA>=1,posB>=1,posC>=1,posD>=1; posA-=1,posB-=1,posC-=1,posD-=1) // goes from 180 degrees to 0 degrees
{
Aservo.write(posA); // tell servo to go to position in variable 'posA'
Bservo.write(posB); // tell servo to go to position in variable 'posB'
Cservo.write(posC); // tell servo to go to position in variable 'posC'
Dservo.write(posD); // tell servo to go to position in variable 'posD'
delay(15); // waits 15ms for the servo to reach the position
}
}
[/code]
L_JESSIE
it is very simple,
you can connect 4 servo to the model
and try this code .
You can change the date which you need.
[code]
#include <Servo.h>
Servo Aservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
Servo Bservo;
Servo Cservo;
Servo Dservo;
int posA = 0; // variable to store the servo position
int posB = 0;
int posC = 0;
int posD = 0;
void setup()
{
Aservo.attach(2); // attaches the servo on pin 2 to the servo object
Bservo.attach(3); // attaches the servo on pin 3 to the servo object
Cservo.attach(9); // attaches the servo on pin 9 to the servo object
Dservo.attach(11); // attaches the servo on pin 11 to the servo object
}
void loop()
{
for(posA = 0,posB = 0,posC = 0,posD = 0; posA < 180,posB < 180,posC < 180,posD < 180; posA += 1,posB += 1,posC += 1,posD += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
Aservo.write(posA); // tell servo to go to position in variable 'posA'
Bservo.write(posB); // tell servo to go to position in variable 'posB'
Cservo.write(posC); // tell servo to go to position in variable 'posC'
Dservo.write(posD); // tell servo to go to position in variable 'posD'
delay(15); // waits 15ms for the servo to reach the position
}
for(posA = 180,posB = 180,posC = 180,posD = 180; posA>=1,posB>=1,posC>=1,posD>=1; posA-=1,posB-=1,posC-=1,posD-=1) // goes from 180 degrees to 0 degrees
{
Aservo.write(posA); // tell servo to go to position in variable 'posA'
Bservo.write(posB); // tell servo to go to position in variable 'posB'
Cservo.write(posC); // tell servo to go to position in variable 'posC'
Dservo.write(posD); // tell servo to go to position in variable 'posD'
delay(15); // waits 15ms for the servo to reach the position
}
}
[/code]
