Example Code for Raspberry Pi - Get gesture by polling
This tutorial shows how to get gesture data on a Raspberry Pi using a polling method.
Hardware Preparation
- Raspberry Pi 4 Model B (or similar) × 1
- Gravity: GR10-30 Gesture Sensor × 1
- DuPont Wires × 1
Software Preparation
Other Preparation Work
Driver Installation
-
Enable I2C of Raspberry Pi. Skip this step if it is already enabled. Open terminal and input the following command and press Enter:
pi@raspberrypi:~ $ sudo raspi-config
Then use the UP/Down keys to select "5 Interfacing Options", press Enter, select "P5 I2C" and press Enter to comfirm "Yes". Reboot the Raspberry Pi board. -
To install Python dependency library and git, the Raspberry Pi needs to be connected to the Internet. Skip this step if they're already installed. In the terminal, input the following command and press Enter:
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install build-essential python-dev python-smbus git -
Download DFRobot_GR10_30 driver library. In the terminal, input the following command and press Enter:
pi@raspberrypi:~ $ cd Desktop/
pi@raspberrypi:~/Desktop $ git clone https://github.com/DFRobot/DFRobot_GR10_30
Sample Code
- In the terminal, input the following command and press Enter to run the sample code:
pi@raspberrypi:~/Desktop $ cd DFRobot_GR10_30/python/raspberry/example/
pi@raspberrypi:~/Desktop/DFRobot_GR10_30/python/raspberry/example/ $ python get_getures.py
Was this article helpful?
