This post will show how to take advantages of The Tactigon’s BLE Central capabilities. We wanted to control our robot by using The Tactigon as a “3D steering wheel” controlling speed with pitch and steering with roll. We made so few changes in the Alphabot2 original Bluetooth example code and wrote a sketch for The Tactigon to connect to the robot’s BLE characteristic and write in wheels speeds.
After our environment is configured and our boards are ON, we need to gather BLE MAC Address and Characteristic. To do so we used a free android application called BLE Scanner.
Few seconds after the application should show the robot’s BLE:
As we see, all BLE devices around us are showed in this section. We need to write down the Waveshare_BLE MAC address: in this instance it is: 00:0E:0B:0C:4A:00
By clicking on the CONNECT button we access to device’s informations as attribute, service and custom characteristic.
Here we need to write down the CUSTOM CHARACTERISTIC UUID, in this case: 0000ffe1-0000-1000-8000-00805f9b34fb .
With this items we can set our Tactigon BLE to act as BLE Central in the setup() section of the code.
Analizyng pitch angle provided by Tactigon library, we can determine steering radius by slowing internal wheel and accelerating external wheel.
Analizying roll, instead, we can determine travel speed of the robot.
With a sprintf we prepare the buffer to write in the characteristic.
To parse the command we first read all the serial buffer and verify if it is longer than 0:
If the command contains “Wh” we can so parse the string and gather leftSpeed and rightSpeed.
The direct_motor function assign the speed transmitted by The Tactigon to each wheel of the robot. By doing so The Tactigon will act as a virtual-steering wheel!