Hi everyone
There is a problem with compiling the codes to compensate for the drift in my helicopter using gyro rate sensors
can anyone help me with it ?
#include <Servo.h>
Servo myservo1;
Servo myservo2;
int potpin =0;
int gyropin = 1;
int joypin= 2;
int levelpin= 3;
int val1;
int val2;
int val3;
int val4;
int val5;//variable to read the main rotor gyro
int sum1;
int sum2;
void setup()
{
myservo1.attach(9);//control tail motor through pin 9
myservo2.attach(10);//control main rotor through pin 10
}
void loop()
{
val1=analogRead(potpin);
//(value between 0 and 1023) - read the value of the potentiometer
val1= map(val1,0,1023,0,179);
//(value between 0 and 180)-scale it to use with servo
val2=analogRead(gyropin);
//(value between 0 and 1023)- to read the value of the potentiometer
val2=map(val2,0,1023,0,179);
//(value between 0 and 180)-scale it to use with servo
val3=analogRead(joypin);
//(value between 0 and 1023)- to read the value of the potentiometer
val3=map(val3,0,1023,0,179);
//(value between 0 and 180)-scale it to use with servo
val5 = analogRead(levelpin);
// read the potentiometer(value between 0 and 1023)
val5 = map(val5,0,1023,0179);
//(value between 0 and 180)-scale it to use with servo
val4 = 1500 - val3;
sum1 = (0.15 *val4)+ (0.7 * val1) + (0.15 * val2);
sum2 = (0.25 * val5)+(0.75 * val1);//mixing
myservo1.write(sum1);
//set the servo position according to the scaled value
delay(15);
myservo2.write(sum2);
//set the main rotor to the potentiometer
delay (15);
}