Robohub Tech
Robohub Tech
  • 1
  • 61 951
How to control servo using MPU6050 Gyroscope with Arduino
How to control servo using MPU6050 Gyroscope with Arduino:
In this quick tutorial we will control an SG90 servo or any generic servo using MPU6050 triple-axis Gyroscope and accelerometer module.
MPU6050 Wiring:
SCL - A5
SDA - A4
VCC - 3.3V
GND - GND
INT - PIN3
Servo Wiring:
VCC - 5V
GND - GND
Control - PIN3
Please note you can use other pins but you will have to change it in the code.
Download the sketch:
drive.google.com/file/d/0B0SU0douW9lVenJ0Vng0QlEyUDQ/view?usp=sharing
In order for the sketch to work you will need to install i2cdevlib library to Arduino library folder:
github.com/jrowberg/i2cdevlib
The sketch is based on i2cdevlib library example except some additions for controlling the servo.
I created this video with the TH-cam Video Editor (th-cam.com/users/editor)
มุมมอง: 61 954

วีดีโอ

ความคิดเห็น

  • @nameerlatef2079
    @nameerlatef2079 3 หลายเดือนก่อน

    Can you do it with a stepper motors?

  • @braydentervort9834
    @braydentervort9834 ปีที่แล้ว

    DOES NOT WORK!😡

  • @shinymeatball6735
    @shinymeatball6735 2 ปีที่แล้ว

    Whydid you commen thalf the code?

  • @murlidewangan4277
    @murlidewangan4277 2 ปีที่แล้ว

    "Wire" was not declared in the scope How solve this problem ❓❓

  • @mochammadasyari6522
    @mochammadasyari6522 3 ปีที่แล้ว

    help me, I'm still a beginner why my library doesn't support Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno" C:\Users\asus\Downloads\MPU6050_DMP6\MPU6050_DMP6.ino:46:20: fatal error: I2Cdev.h: No such file or directory #include "I2Cdev.h" ^ compilation terminated. exit status 1 Error compiling for board Arduino/Genuino Uno. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

  • @ThivaharanS
    @ThivaharanS 3 ปีที่แล้ว

    DMP Initialization failed

  • @CemCavkaytar
    @CemCavkaytar 3 ปีที่แล้ว

    Merhaba Ben Bu Malzemelerle sallantı esnasında bir tepsinin üzerinde bardak ve suyun dökülmemesini istiyorum onu nasıl yaparız. Teşekürler.

  • @DanSavage99
    @DanSavage99 3 ปีที่แล้ว

    Can you explain why this only works when connected to the USB? When I disconnect the USB and plug in external power, the servo goes to '0' position and gyro no longer controls servo. LED blinks in pulses of 3. (blink, blink, blink, off, repeat)

    • @DanSavage99
      @DanSavage99 3 ปีที่แล้ว

      I found the problem. The transformer I was using only put out 7.5V @250mA. This was causing the 5V in the Arduino to drop to 4.9V instead of 5V. Once I hooked up a battery that supplies 12V, it works fine.

  • @dominicsworkshop
    @dominicsworkshop 3 ปีที่แล้ว

    the code would not compile :( bad video

  • @animemafia2085
    @animemafia2085 3 ปีที่แล้ว

    Can you make it with 2 servo

  • @tonkhoonkramol2208
    @tonkhoonkramol2208 4 ปีที่แล้ว

    And​ what​ code​ how​ to​ control​2​ servo​ with​ gyro

  • @tjkennedy380
    @tjkennedy380 4 ปีที่แล้ว

    What about 2 axis

    • @RobohubTech
      @RobohubTech 4 ปีที่แล้ว

      Hi TJ, Of course you can control two or more servos, but of course you want to change the code.

  • @tjkennedy380
    @tjkennedy380 4 ปีที่แล้ว

    Can I use a raspberry pi instead

    • @valerafox7795
      @valerafox7795 2 ปีที่แล้ว

      Ofc, it can even much much much more than that. We using it because it's cheap and small and fits lots of needs and also won't drain battery - just optimized for such projects more than Raspberry Pi. Someone seriously uses them simply as a PC to work/ even gaming. 😂😅😓

  • @mattgml170
    @mattgml170 4 ปีที่แล้ว

    I can put 2 servo?

    • @RobohubTech
      @RobohubTech 4 ปีที่แล้ว

      Yes absolutely, but you need to change the code to also control the other servo. we will post a new video showing how to control 3 servos soon.

  • @firozdang
    @firozdang 4 ปีที่แล้ว

    I am able to build this and make it functionally work thanks!

  • @ninuvlog7694
    @ninuvlog7694 4 ปีที่แล้ว

    Do video with two servos please

    • @RobohubTech
      @RobohubTech 4 ปีที่แล้ว

      Thanks Mohammed, we will post the video soon.

  • @PASStaCreations
    @PASStaCreations 5 ปีที่แล้ว

    as your video guide you forget to mention the int pin and control pin as the 3 but the example code you have sketch were int 2 and control 9 please change code and edit the link....

  • @rupasomm8449
    @rupasomm8449 5 ปีที่แล้ว

    The Link shown gives a huge codewith lot of instructions , can you please give a code pertinent to this project only.

    • @firozdang
      @firozdang 4 ปีที่แล้ว

      you have to connect to serial monitor and enter any alphabet to start the run, then it will start working

  • @akshaydevanpally3764
    @akshaydevanpally3764 5 ปีที่แล้ว

    Thanks alot for the help

  • @TheNikhilmishras
    @TheNikhilmishras 5 ปีที่แล้ว

    The code is cool! thnx! but how do I understand the code?

  • @rumahhafidzahbekasi1354
    @rumahhafidzahbekasi1354 6 ปีที่แล้ว

    Hhmmm... i wonder if i can use it as an drone camera gimball.

  • @jameselliott9397
    @jameselliott9397 6 ปีที่แล้ว

    Sketch link does not work. Can you post sketch in comments?

  • @Kreazive
    @Kreazive 6 ปีที่แล้ว

    I got "⸮⸮⸮⸮#!⸮⸮(⸮⸮⸮⸮" from Serial Monitor

    • @Nik4toon
      @Nik4toon 6 ปีที่แล้ว

      go to tool then serial monitor set the baud 115200 all the best!

    • @Project_Dragon
      @Project_Dragon 5 ปีที่แล้ว

      me too. I recommend you to: make sure INT on the gyro is connected to 3, reset the Arduino, upload it the program, and open the serial monitor then type a. I hope I helped

  • @wannandaf.1751
    @wannandaf.1751 6 ปีที่แล้ว

    Do you have any programming for arduino mega 2560?

    • @Ganeshaynamah007
      @Ganeshaynamah007 2 ปีที่แล้ว

      programming is same for arduino uno and mega. only 'arduino mega 2560' has to selected in arduino ide before uploading the programming

  • @galenstevenson488
    @galenstevenson488 6 ปีที่แล้ว

    I get the readouts from gyro, but servo doesn't do anything. If I run generic servo sketch, I can confirm servo functions... but doesn't work for this. Tried a few different pin outs just in case. Halp!

  • @nesar93
    @nesar93 6 ปีที่แล้ว

    Works only for about 5 seconds, then the serial monitor abruptly stops and so does the servo. Seems to be some error with the code. Kindly make necessary changes so that it runs for endlessly without errors.

    • @valerafox7795
      @valerafox7795 2 ปีที่แล้ว

      Such things don't happen due to error code, as I saw on my experience. Mostly the troubles happened in my projects with multiple servos, and just barely enough power supply. Mostly you need a good one

  • @balajivannikumar3170
    @balajivannikumar3170 6 ปีที่แล้ว

    Library please

    • @Project_Dragon
      @Project_Dragon 5 ปีที่แล้ว

      What's your problem? I managed to get mine working but it was not like the video.

  • @machine2747
    @machine2747 6 ปีที่แล้ว

    Does this even work? I installed the libraries and get error after error.. Freertos.h is no where to be found....

    • @Project_Dragon
      @Project_Dragon 5 ปีที่แล้ว

      Yes it does. So first thing you want to do is unzip the zip file, look in all the folders for the file you need and remember the location of it, go to the Arduino sketch and do this but with the folder th-cam.com/video/jMSic83Prs8/w-d-xo.html( 1:11 - 1:40 ). I hope I helped don't forget to type a in the serial monitor. :)

  • @daniel_dz9517
    @daniel_dz9517 6 ปีที่แล้ว

    Hi..im using gy-25 module and it doesn't have int pin.. please tell me what should I do?? It has..(SDA)(SCL)(BO)(RST)(VCC)(RX)(TX)(GND).

  • @ksmith7122
    @ksmith7122 6 ปีที่แล้ว

    "INT - PIN3" This should be "INT - D2" becasue the interupt pin on the arduino is digital pin D2. Also "Control - PIN3" should be "Control - D9" as the servo control signal goes to digital pin D9

  • @ksmith7122
    @ksmith7122 6 ปีที่แล้ว

    In linux here is the code I used to get J Rowberg's i2cdevlib library installed and usable. You will need git installed, or just unzip to achieve the same as the below. My Arduino library directory is at /home/user/Desktop/arduino-1.8.5 Here is the simple code cd /home/user/Desktop/arduino-1.8.5/libraries git clone github.com/jrowberg/i2cdevlib.git cd /home/user/Desktop/arduino-1.8.5/libraries/i2cdevlib/Arduino mv I2Cdev /home/user/Desktop/arduino-1.8.5/libraries mv MPU6050 /home/user/Desktop/arduino-1.8.5/libraries cd /home/user/Desktop/arduino-1.8.5/libraries sudop chmod 777 -R * rm -rf /home/user/Desktop/arduino-1.8.5/libraries/i2cdevlib

  • @lajazzhot
    @lajazzhot 6 ปีที่แล้ว

    Hi I'm a begginer with all this so bare with me please. I'm running this very happily on a trinket pro but have one problem I cant solve. It only works when I have the ftdi connected to the computer any ideas?

  • @debajyotidas7322
    @debajyotidas7322 6 ปีที่แล้ว

    Does it need to connected with computer?? Reply fast

    • @yoman4204
      @yoman4204 6 ปีที่แล้ว

      MAKE SOMETHING CREATIVE. Yes to upload code on Arduino

  • @ricobotma6302
    @ricobotma6302 6 ปีที่แล้ว

    can you paste the codes in the description

  • @jackmanjls
    @jackmanjls 6 ปีที่แล้ว

    can't download sketch

  • @RAJENDRAMYTHILIBIS
    @RAJENDRAMYTHILIBIS 6 ปีที่แล้ว

    please upload the code

  • @muhammadrizkiramadhan8557
    @muhammadrizkiramadhan8557 7 ปีที่แล้ว

    Can i change the servo to brushless motor?

    • @MightyTechGuy
      @MightyTechGuy 7 ปีที่แล้ว

      you can control the rpm using of brushless motor.. You can even control the direction.. but i dont think that gyroscope is a suitable sensor for such application.. Subscribe my channel for similar tech info..:)

    • @padmanabhanrajesh2366
      @padmanabhanrajesh2366 6 ปีที่แล้ว

      Yes,but firstly you should calibrate the esc

  • @dulangaperera7977
    @dulangaperera7977 7 ปีที่แล้ว

    But I get error though I downloaded the zip file.

    • @dulangaperera7977
      @dulangaperera7977 7 ปีที่แล้ว

      plz help me.

    • @RobohubTech
      @RobohubTech 7 ปีที่แล้ว

      Hi Dulanga Perera, What is the error?

    • @dulangaperera7977
      @dulangaperera7977 7 ปีที่แล้ว

      mpu.initialize();

    • @dulangaperera7977
      @dulangaperera7977 7 ปีที่แล้ว

      adding library part is done. but now i get this error. i'm beginner to arduino. so please help me.