Controlling of Servo motor with Arduino and MPU 6050

Controlling of Servo motor with Arduino and MPU 6050

Controlling of Servo motor with Arduino and MPU 6050
Controlling of Servo motor with Arduino and MPU 6050 Final image

 

Controlling of Servo motor with Arduino and MPU 6050

In this article we will learn how to make Controlling of Servo motor with Arduino and MPU 6050.

In the last post we will learn how to make Motor speed control Using IBT2 and Arduino. You can visit our website,
I hope you appreciate my work, let’s discuss about today’s project.

 

 

 

 

 

 

Table of Content:

1.    Components

2.    What is MPU-6050

3.    Amazon Links

4.    How MPU-6050 works

5.    Circuit Connection

6.    Usage

7.    Programming code

 

Components:

  1. Arduino Uno
  2. Motor Driver (MPU-6050)
  3. Battery (9V)
  4. Servo motor
  5. Jumper wires

What is MPU-6050?

The MPU-6050 is a popular integrated circuit (IC) or sensor module that combines a 3-axis gyroscope and a 3-axis accelerometer in a single component.

This module is commonly used in various electronic devices, especially in motion-tracking applications and inertial sensing systems.

The MPU-6050 is capable of measuring acceleration along three axes (x, y, and z) and rotational motion or angular velocity around those same axes. It communicates with other devices or microcontrollers through protocols like I2C (Inter-Integrated Circuit) or SPI (Serial Peripheral Interface).

Amazon Links

Arduino Nano

Arduino UNO

MPU 6050 module

Liquid Crystal LCD display 16×2

Other Tools and Components: 

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

How MPU-6050 Works?

The MPU-6050 is a popular sensor module that combines a gyroscope and an accelerometer.

Here’s how it works:

  • Gyroscope:

The gyroscope in the MPU-6050 measures the rate of rotation or angular velocity around three axes (X, Y, Z). It works based on the principle of Coriolis force.

  • Accelerometer:

The accelerometer measures acceleration forces acting on the sensor along the same three axes (X, Y, Z). It operates using microscopic structures that get displaced due to the force of acceleration.

Circuit Connection:

  • Connect signal pin of Servo motor with pin 9 of Arduino
  • Connect VCC pin of Servo motor with +ve terminal of 9V Battery
  • Connect –ve terminal of Battery with GND pin of Arduino through –ve terminal of Servo motor
  • Connect VCC pin of MPU-6050 module with 5V pin of Arduino
  • Connect GND pin of MPU-6050 module with GND pin of Arduino
  • Connect SCL pin of MPU-6050 module with A5 pin of Arduino
  • Connect SDA pin of MPU-6050 module with A4 pin of Arduino

Circuit Diagram: 

Controlling of Servo motor with Arduino and MPU 6050
Controlling of Servo motor with Arduino and MPU 6050 Circuit Diagram

Usage of MPU-6050…

  1. Motion Sensing:

The MPU-6050 can detect and measure acceleration, enabling it to determine the movement of an object in three dimensions.

  1. Gyroscope:

It contains a gyroscope that measures angular velocity, allowing it to determine the rate of rotation around various axes.

  1. Gesture Recognition:

By combining data from the accelerometer and gyroscope, the MPU-6050 can recognize certain gestures or movements, which is useful in applications like gesture-controlled devices or games.

  1. Navigation and Positioning:

In combination with other sensors or algorithms, the MPU-6050 can contribute to determining an object’s position or orientation in space.

  1. Robotics and IoT:

It’s utilized in various robotics projects and Internet of Things (IoT) devices where accurate motion sensing is required.

Programming code…

[dt_code]

#include <Adafruit_MPU6050.h>

#include <Adafruit_Sensor.h>

#include <Wire.h>

#include <Servo.h>

 

Servo servo;

Adafruit_MPU6050 srituhobby;

 

void setup(void) {

Serial.begin(115200);

servo.attach(3);

Wire.begin();

srituhobby.begin();

servo.write(0);

 

srituhobby.setAccelerometerRange(MPU6050_RANGE_8_G);//2_G,4_G,8_G,16_G

srituhobby.setGyroRange(MPU6050_RANGE_500_DEG);//250,500,1000,2000

srituhobby.setFilterBandwidth(MPU6050_BAND_21_HZ);

 

delay(100);

}

 

void loop() {

 

/* Get new sensor events with the readings */

sensors_event_t a, g, temp;

srituhobby.getEvent(&a, &g, &temp);

 

int value = a.acceleration.y;

 

value = map(value,  -10, 10, 180, 0);

servo.write(value);

Serial.println(value);

//delay(10);

 

}

[/dt_code]