Using a Gyro to control my projects was a big thing on my bucket list but apart from acquiring the IMU the rest was hard as nails. The lack of effective content on extracting yaw pitch and roll values bugged me for over a month. After numerous websites, countless libraries and problems I learned to get data from the gyro and use it in a simple project that beginners can easily do and save themselves a lot of trouble.
So here's a instructable to get you started on this Accelerometer - Gyroscope sensor and by the end of it you'll be able to turn your robot exactly the amount you wish.(90 degrees, 45 degrees ,180 degrees.....anything)
Most of the electronis can be bought in your local electronics store or online
Here are they:
DIY 4WD Double-Deck Smart Robot Car Chassis Kits with Speed Encoder RC Robot from Toys Hobbies and Robot on banggood.com
You could also use a 2 wheel chassis with a caster wheel.
Geekcreit® Arduino Compatible UNO R3 ATmega16U2 AVR USB Development Main Board Module Board For Arduino from Electronics on banggood.com
IMU - MPU6050 6DOF
6DOF MPU-6050 3 Axis Gyro With Accelerometer Sensor Module For Arduino Module Board For Arduino from Electronics on banggood.com
Male to male
Female to male
L298N Motor Driver
Geekcreit® L298N Dual H Bridge Stepper Motor Driver Board For Arduino Module Board For Arduino from Electronics on banggood.com
ZOP Power 11.1V 2200MAH 3S 30C Lipo Battery XT60 Plug RC Parts from Toys Hobbies and Robot on banggood.com
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Step 1 : Assemble Your Chassis
Assemble your Bot chassis lol.
Refer the fritzing image above but if you struggle , i'm just a comment below
Step 2: Installing MPU6050 Library
It's important to note that if you happen to have a library installed for your MPU6050 REMOVE IT or it will flag compilation errors.
Instead use this link to download the library and add it using Include library under Sketch.
Step 3: Connections
On installing the library go ahead and wire up the
The connections to the motor driver are given in the code itself.
ena = 5;
enb = 6;
in1 = 7;
in2 = 4;
in3 = 9;
in4 = 8;
here’s it anyway :)
The connections between the Arduino and the sensor are :
VCC - +5V
GND - GND
SDA - A4
SCL - A5
Note - From here on we call the robot Barney.
Step 4: Code
Copy this code below and paste it on your IDE and upload.
Don't plug your sensor in the bread board as the wires and electronics may create noise which will affect the accuracy of your YAW PITCH ROLL values
While running the bot just set the bot on the floor and press reset so the sensor calibrates properly.
We only use the Yaw values for this project so keep that in mind while mounting your sensor.
Use double sided foam tape to stick the sensor to the front of your bot.
This instructable taught you to use a gyroscope in a simple robotics design and you can experiment with your own ideas as you now know the implementation.
Feel free to Ask anything in the comments.
Participated in the