Inertial Measurement Units
Last updated
Was this helpful?
Last updated
Was this helpful?
Wiring:
Arduino
MPU 6050
GND
GND
5V
Vcc
SCL
A5
SDA
A4
Starter Code To Read Data from your MPU6050:
Guided Exercises for the Above Code
Begin by getting your sensor wired up and your code up and running. Open up your serial monitor and hold your sensor still while it calibrates. Then move it around in all directions.
Comment out all the sensor readings except for:
Your loop should now look like this:
Re-upload the code.
Now that you don’t have so much data to look at you should be able to figure out what angle Z is telling you... (HINT: if you keep your IMU poited upwards, you should be able to spin it and see the Z angle changing!
This sensor can tell you a lot of things! Comment and uncomment different readings until you understand what the different values mean.
Some things to try:
Wire up a speaker (or an LED) and your IMU. Turn on the buzzer (or LED) when the IMU is tilted more than 45 degrees away from it’s normal angle (flat). (HINT: look back at the Making Sound Lesson!)
Wire up your LED Matrix and your IMU. Display a little dot in the middle of the LED Matrix and have it move around the LED matrix as you tilt your IMU. Ideally this should function as a tool to help you make sure a table is level.
Wire up your LCD screen and your MPU (two devices using I2C at the same time!). Use the data from your IMU to detect up/down motion (like a step). Use this detection to count steps like a pedometer! Display the step count on your LCD screen.
Build a little stand out of cardboard that you can hook up to your Servo and attach your IMU to the top. Write some code so that if you tip your servo/IMU forward/backward, the servo will spin to keep the cardboard stand horizontal. In other words, the table that the IMU is sitting on should always stay parallel to the ground. Here is my video guide for this one: