In order for the project to work, make sure to calibrate both ESC before running the main code. You gotta make sure you have installed the Servo and Wire Arduino libraries.
#include <Servo.h>
#include <Wire.h>
To read MPU6050's raw accelerometer and gyroscope data, we must register our MPU's hex addresses. Just as follows:
// Accelerometer raw data
Acc_rawX = Wire.read() << 8 | Wire.read();
Acc_rawY = Wire.read() << 8 | Wire.read();
Acc_rawZ = Wire.read() << 8 | Wire.read();
// Gyro raw data
Gyr_rawX = Wire.read() << 8 | Wire.read();
Gyr_rawY = Wire.read() << 8 | Wire.read();
If you'd like to make any changes, you can check the MPU6050's datasheet anytime you want.
Ideal aero PID controller structure.
We can use any Arduino board, as long as SDA and SCL pins are available.