Can't understand how servo works!

Hi guys,

I'am trying to create a quadcopter and I'am stuck on the servos, well i just want to know how does these works.
I used the libray Servo and the function Servo1.write(angle) it doesn't works but if i use the example of knoob which is a FOR that increase the angle from 0 to 180 it works.
I looked about the servo in the internet but I didn't understand much :cry: :cry: :cry: :cry:
I just cannot understand how to give power to 4 motors at the same time.....
If there is anyone that could help me i would be very pleased

I just cannot understand how to give power to 4 motors at the same time.....

Servos need an external power supplys, do not power them from the arduino.

Did you use servo.attach(pin); ?

zoomkat:
Servos need an external power supplys, do not power them from the arduino.

Isaac96:
Did you use servo.attach(pin); ?

Thanks for the replys, I have a supply battery and I also used the attached!!

Could you post your code that doesn't work?

Are you performing the proper arming sequence for your ESCs?

Hi,
How are you using servos on a quadcopter.
Can you post a picture of your servos and controller.

What is your electronics, programming, arduino, hardware experience?

Tom..... :slight_smile:

Isaac96:
Could you post your code that doesn't work?

#include <Wire.h>
#include <Servo.h>

Servo bl; //back left
Servo fl; //front left
Servo fr; //front right
Servo br; //back right
int potenza=0;

byte ricevuto[3];
int cont=0;
int pos;
boolean l= false;
boolean r = false;

void setup()
{

bl.attach(2);
fl.attach(7);
fr.attach(9);
br.attach(11);

pinMode(13, OUTPUT);
Wire.begin(4); // i2c
Serial.begin(9600);
Serial.println("ciao");
// inizializzo seriale
Wire.onReceive(receiveEvent); // register event

}

void loop()
{
if(l==true)
{
l=false;
potenza=ricevuto[1];

bl.write(ricevuto[1] + ricevuto[0]);
delay(10);
fl.write(ricevuto[1]);
delay(10);
fr.write(ricevuto[1] + ricevuto[0]);
delay(10);
br.write(ricevuto[1]);
delay(10);
}

if(r==true)
{
/* r=false;
bl.write(potenza + ricevuto[1]);
delay(10);
br.write(potenza + ricevuto[1]);
delay(10);*/

}

delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
while(0 < Wire.available()) // loop through all but the last
{
for(int i=0; i<3; i++)
{
ricevuto*=Wire.read();*
_ Serial.print(ricevuto + ",");_
* }*
* Serial.println("");*

if(ricevuto[cont] != 108 || ricevuto[cont]!= 114)
* cont++;*

* else if(ricevuto[cont] == 108 )*
* {*
* cont=0;*
* l = true;*
* }*

* else*
* {*
* cont=0;*
* r=true;*
* }*
* digitalWrite(13, HIGH);*
* }*

}
> cr0sh:
> Are you performing the proper arming sequence for your ESCs?
Sorry I don't get when you say arming if you mean the calibration of the escs I already did it!!
> TomGeorge:
> Hi,
> How are you using servos on a quadcopter.
> Can you post a picture of your servos and controller.
>
> What is your electronics, programming, arduino, hardware experience?
>
> Tom..... :slight_smile:
Well I use an arduino yun and a Crius that works as an arduino mega it's used for quadcopters to connect the escs, i connect them through I2C , i don't have a controller i just controll them with an app created to android, so to sum up briefly I'am creating a quadcopter controlled by app(android) ,which send data to yun and this will send it to the crius by I2C and then it will give the istruction to motors to move!!!
I am a junior programmer =)
Thanks for everyone !!!

Each of the 4 motors needs input from each of the pitch/roll/yaw/thrust inputs, something like:

  tl = thrust + pitch + roll + yaw ;
  tr = thrust + pitch - roll - yaw ;
  br = thrust - pitch - roll + yaw ;
  bl = thrust - pitch + roll - yaw ;

Where the thrust/pitch/roll/yaw values are suitably scaled and limited and each driven from a PID
loop.