Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 22.5 ('Gyroscope')
Instant purchase and download via GumRoad!

FEATURE

Balancing Act

Using an accelerometer and gyroscope sensor with your Raspberry Pi

Issue: 22.5 (September/October 2024)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He has university degrees in the disciplines of Engineering, Chemistry, Biology, Business, and a Ph.D. in Chemical Engineering. He is the author of dozens of books on Xojo available on the xdevlibrary.com website.
Article Description: No description available.
Article Length (in bytes): 21,320
Starting Page Number: 21
Article Number: 22503
Resource File(s):

Download Icon project22503.zip Updated: 2024-09-02 10:58:57

Related Web Link(s):

>wget http

Excerpt of article text...

The MPU6050 measures acceleration and the position of an object. It is used for drones, self-balancing robots, vehicle tilt sensors, and to detect rotation. This is a common chip used in the industry and can be purchased for a number of Raspberry Pi and Arduino-compatible boards.

For instance, the latest Chevrolet ZR2 truck has a tilt sensor that is used to measure the angle of the truck when driving off the main road. If you want to ensure that a drone or quadcopter remains level, then an MPU6050 may be a good choice.

What makes the MPU6050 unit even better is that it uses I2C communication, which requires only a few wires! Roll and pitch are common measurements. The MPU6050 would work well with an additional compass gauge to reliably measure yaw and an elevation gauge to measure the height above the ground.

This example and the accompanying free library calculates the angles in the x-axis and y-axis directions, acceleration, and all the raw accompanying data. Equipment used includes a Raspberry Pi 5, MPU6050, Xojo 2023 R4, Raspberry Pi OS, and the free lgpio library. A video of the running example is available on YouTube (https://youtu.be/gNzrLWRh18Q). See Figure 1.

The final result is to calculate the x-axis and y-axis angles in degrees and display them on the screen. Raw gyroscope and acceleration data are read from the MPU6050, and only the first decimal point is shown for each value.

...End of Excerpt. Please purchase the magazine to read the full article.


Home | Store | Browse Published Issues | Customer Service | Contribute | xDevLibrary

Site Copyright 2002-2024 by xDev Magazine and DesignWrite.
Xojo is a trademark of Xojo, Inc..