Gesture Loop Sample

This sample demonstrates detecting hand gestures.

To run the sample:

  1. 2.
    Copy the sample code to a folder on the Raspberry Pi.
  2. 3.
    Open terminal, and then go to the folder you copied the sample.
  3. 4.
    Run the sample with the following command:

Sample Code
#!/usr/bin/env python3
#This sample demonstrates detecting hand gestures.
#Install IoT HAT 3 library with "pip3 install turta-iothat3"
from time import sleep
from turta_iothat3 import Turta_Light
from turta_iothat3 import Turta_Buzzer
light = Turta_Light.LightSensor(Turta_Light.MODES.PROX_GES)
buzzer = Turta_Buzzer.BuzzerDriver()
while True:
#Check gestures
g = light.read_gesture()
if g is not None:
print("Gesture Detected: " + str(g))
#Exit on CTRL+C
except KeyboardInterrupt:


When you run the sample, it looks for a gesture data in every loop. When it detects one, prints the direction. The example output should be like this:
Gesture Detected: GESTURES.LEFT
Gesture Detected: GESTURES.RIGHT
Gesture Detected: GESTURES.UP
Gesture Detected: GESTURES.DOWN
To stop the Python script, just press CTRL + C.