Testing the gesture controller

The code for this project can again be found at https://github.com/PacktPublishing/MicroPython-Projects/tree/master/ch7.

Download the code and then copy it to your development board. If you aren't using an STM32L475 IoT Discovery node, you may need to modify the LED pins or the I2C bus you are using, but otherwise, the application should run without any other issues.

Once the application and the APDS-9660 module are copied to your MicroPython board, in the REPL, press Ctrl + D. This will perform a soft reboot and start the application. You can now present the APDS-9660 with a gesture. If you swipe right, you should see Right! in the REPL, along with one of your LEDs turning on. If you swipe left, you'll see Left! and the LED associated with it will turn on. The LEDs should turn off within 5 seconds. If you find this is too long, change the timeout value to something such as 2000 to get a 2-second timeout.

If you present the controller with right, left, forward, and then backward gestures, you should see something very similar to the following screenshot. It is showing the gesture control application output when presented with a right gesture, a left gesture, a forward gesture, and a backward gesture:

If you want to see the gesture data, you can press Ctrl + C and then initialize the gesture object with True. When you do this and then do a right swipe, you may see data similar to that in the following screenshot:

The preceding screenshot shows the debug output for a right-swipe gesture. The data order for the photodiodes is up, down, left, and right.

Congratulations! You now have a gesture controller that you can use in your own projects! 

Note: For anything that moves, you will want to improve the robustness of the code and take into account a backup control in case the gesture controller fails or provides erroneous data.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.172.249