hey guys. i am very new to arduino and i am making a quadcopter, i have a lot of issues with programming and my quad wont fly can anyone just help me out with the code that i should use. ill give you the details about my quad. all i want is to hover my quad for the time being.this will be your utmost kindness if you can simply provide me with the code
i am using :
arduino uno,
GY-80,
1000KV MOTORS,
30 A ESC,
5000mah ,3s ,11.1V battery
6ch transmitter receiver.
this is the program that i had written(apologies for the silly mistakes):
#include<Servo.h>
Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;
int chPin1 = 6, chPin2 = 7, chPin3 = 8, chPin4, chPin5 = 12, chPin6;
int ch11, ch33;
int throttle;
void setup() {
pinMode(chPin1, INPUT);
pinMode(chPin3, INPUT);
pinMode(chPin5, INPUT);
pinMode(chPin2, INPUT);
motor1.attach(A1);
motor3.attach(A3);
motor2.attach(A2);
motor4.attach(A0);
}
void loop() {
chPin3 = pulseIn(chPin3, HIGH, 50000);
chPin1 = pulseIn(chPin1, HIGH, 50000);
ch33 = map(ch33, 1000, 2000, -50, 50);
ch11 = map(ch11, 1000, 2000, -50, 50);
throttle = pulseIn(chPin2, HIGH, 50000);
if (digitalRead(chPin5) == 1) {
motor1.writeMicroseconds(throttle + ch33 - ch11);
motor3.writeMicroseconds(throttle + ch33 + ch11);
motor2.writeMicroseconds(throttle - ch33 - ch11);
motor4.writeMicroseconds(throttle - ch33 + ch11);
}
else {
motor1.writeMicroseconds(1000);
motor2.writeMicroseconds(1000);
motor3.writeMicroseconds(1000);
motor4.writeMicroseconds(1000);
}
}