Uses the Raspberry Pi 5, Xojo, and MPU6050 to detect tilt and other movements. Prior Raspberry Pi SBC (Single Board Computers) can be used by modifying the lgGpiochipOpen command. This uses the I2C communication protocol.
If you've ever wanted to use your Raspberry Pi to detect tilt and other movements, Eugene is here showing how to connect a gyroscope and accelerometer sensor and read the results with Xojo.
Ensure I2C is enabled on the Raspberry Pi.
To use the lgpio with Raspberry Pi 4 or older systems, get the successful chip handle (not a zero) with the following command:
Initialize the Raspberry Pi 4 lgpio |
---|
MyChipHandle = lgGpiochipOpen(0) //dev/gpiochip0 for Raspberry Pi 4 or older |
To use the lgpio with the Raspberry Pi 5 board, get the chip handle with the following command:
Initialize the Raspberry Pi 5 lgpio |
---|
MyChipHandle = lgGpiochipOpen(4) //dev/gpiochip4 for Raspberry Pi 5 |
Install instructions are:
- install Raspberry Pi OS (64-bit)
- Open a terminal and type the following commands:
- sudo apt install swig python3-dev
- sudo apt install python3-setuptools
- sudo apt install libunwind8
- wget https://github.com/joan2937/lg/archive/master.zip
- unzip master.zip
- cd lg-master
- make
- sudo make install
- open the example program and copy the program and libraries to the RaspberryPi Desktop
- give the executable permission to run with something like: 'sudo chmod +x MPU6050'
- run the program with something like: 'sudo ./MPU6050'