Hi there!

Me and a friend of mine are building our own quadcopter, but we need some help because we’re stuck on the controls.

Here is a quick drawing on how everything is connected:

We use four motors and ESC’s to control our quad. As seen above one ESC and motor are drawn, the others are exactly the same (except for the pin numbers which are 9, 10, 11 and 12).

Both of us are totally new to coding, and we have 0 experience.
The ESC’s respond with a signal width from 700 to 2000. With 700 being a programming mode, and 1000-2000 the flying mode. The motors start spinning at 1047 with minimum speed and go full throttle on 2000.

We can now control all four motors with the same speed, but obviously we need to be able to control each motor individually. Note: we have no gyrostabilisor, so we are not planning on flying outside since this is just a project for school.

We need to be able to set throttle for each motor, but have no idea how.
This is the code we found (and modified) to control four motors (each on their own signal channel 9, 10, 11 and 12).

``````#include <Servo.h>

int value = 0; // set start value

Servo firstESC, secondESC, thirdESC, fourthESC; //includes four ESC's
void setup() {

firstESC.attach(9);
secondESC.attach(10);
thirdESC.attach(11);
fourthESC.attach(12);

Serial.begin(9600);

}

void loop() {

firstESC.writeMicroseconds(value); //select first ESC
secondESC.writeMicroseconds(value); //select second ESC
thirdESC.writeMicroseconds(value); //select third ESC
fourthESC.writeMicroseconds(value); //select fourth ESC

if(Serial.available())
{value = Serial.parseInt();
Serial.println(value);}

}
``````

This code is very simple and we have no idea how to expand it so we can set throttle for each motor.
Our idea was to control the quad from a smartphone with an app via bluetooth, and because the motor throttle goes in steps (1000-2000) we thought it’d be handy to make a sort of step setup, so we can set throttle by +50+100, but for each motor.

So that if we click ‘forward’ the back motors spin +50 faster than the front motors, and if we click ‘up’ all four motors go +50 at once) (NOTE: we have an X-setup quadcopter not a +)

Is someone able to help us out?

TLDR:

We need help with this code so we can set throttle for each motor (pin 9/10/11/12) individually, and throttle/direction goes with steps (throttle ranges from 1000 to 2000) and our idea was throttle would go with +50/-50 etc etc.

Thanks in advance, our project depends on your help because we are stuck!

Individual motors.ino (622 Bytes)

Programmeerprogramma.ino (632 Bytes)

Single motor.ino (707 Bytes)

Both of us are totally new to coding, and we have 0 experience.

Don't worry about the material, IF we actually get it airborne we will make sure it's safely attached to wires so it cannot crash, or hit the ceiling.

We just need help with the code, please someone help us because we're stuck.

Is there really no one who can help us out?

You have chosen a project that is really difficult, even for experienced programmers.

Given this:

Both of us are totally new to coding, and we have 0 experience.