TensorFlow Lite - Magic Wand

Materials

  • AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1

  • Adafruit LSM9DS1 accelerometer

  • LED x 2

Example

Procedure

AMB21 / AMB22 Wiring Diagram:

Connect the accelerometer and LEDs to the AMB21/AMB22 following the diagram.

../../../../_images/image12.jpeg

AMB23 Wiring Diagram: For AMB23, we will use the onboard LEDs on the board itself.

../../../../_images/image1-1.jpeg

BW16 Wiring Diagram: For BW16, we will use the onboard LEDs on the board itself.

../../../../_images/image1-2.jpeg

BW16-TypeC Wiring Diagram: For BW16-TypeC, we will use the onboard LEDs on the board itself.

../../../../_images/image1-36.png

Download the Ameba customized version of TensorFlow Lite for Microcontrollers library at https://github.com/ambiot/tree/master/Arduino_zip_libraries.

Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to install it.

Ensure that the patch files found at https://github.com/ambiot/tree/master/Ameba_misc/ are also installed.

In the Arduino IDE library manager, install the Arduino_LSM9DS1 library. This example has been tested with version 1.1.0 of the LSM9DS1 library.

Open the example, "Files" "Examples" “TensorFlowLite_Ameba” “magic_wand”.

../../../../_images/image21.jpeg

Upload the code and press the reset button on Ameba once the upload is finished.

Holding the accelerometer steady, with the positive x-axis pointing to the right and the positive z-axis pointing upwards, move it following the shapes as shown, moving it in a smooth motion over 1 to 2 seconds, avoiding any sharp movements.

../../../../_images/image32.jpeg

If the movement is recognised by the Tensorflow Lite model, you should see the same shape output to the Arduino serial monitor. Different LEDs will light up corresponding to different recognized gestures. Note that the wing shape is easy to achieve, while the slope and ring shapes tend to be harder to get right.

../../../../_images/image42.jpeg

Code Reference

More information on TensorFlow Lite for Microcontrollers can be found at: https://www.tensorflow.org/lite/microcontrollers