Grove Gesture Example

This example shows how to use the Grove gesture sensor on the board. The gesture sensor can detect 10 gestures as follows:

Raw value read by sensor Gesture
0 No detection
1 forward
2 backward
3 right
4 left
5 up
6 down
7 clockwise
8 counter-clockwise
9 wave

For this notebook, a PYNQ Arduino shield is also required. The grove gesture sensor is attached to the I2C interface on the shield. This grove sensor should also work with PMOD interfaces on the board.


In [1]:
from pynq.overlays.base import BaseOverlay

base = BaseOverlay("base.bit")


1. Instantiate the sensor object


In [2]:
from pynq.lib.arduino import Grove_Gesture
from pynq.lib.arduino import ARDUINO_GROVE_I2C

sensor = Grove_Gesture(base.ARDUINO, ARDUINO_GROVE_I2C)

2. Set speed

There are currently 2 modes available for users to use: far and near. The corresponding fps are 120 and 240, respectively. For more information, please refer to Grove gesture sensor.


In [3]:
sensor.set_speed(240)

3. Read gestures

The following code will read 10 gestures within 30 seconds. Try to change your gesture in front of the sensor and check the results.


In [4]:
from time import sleep

for i in range(10):
    print(sensor.read_gesture())
    sleep(3)


no-detection
no-detection
left
no-detection
no-detection
no-detection
no-detection
down
no-detection
no-detection