In this project, we are going to control a servo motor using the MPU6050 (accelerometer and gyro) sensor. We will connect the servo motor and the MPU6050 sensor with the Arduino in such a way that whenever we move the MPU6050, the servo motor will move according to it.

How Does It Work?





The structure of the accelerometer is a mass attached to a spring which has fixed outer plates and moves along one direction. The capacitance between the plates will change whenever acceleration is applied. This change in capacitance will be measured and will correspond to an acceleration value.

Upon moving the sensor in the upward or downward direction, it gives us values from -17000 to 17000. We will map these from 0 to 180 to move the servo motor. Now when we move the sensor in the upward direction, the output from the sensor will be 180. When we move the move the sensor in the downward direction, then the output of the sensor will be 0.