This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple gesture controller.
In this first article we’re going to learn how to use simple functions of The Tactigon to light up the integrated LEDs intercepting data from internal accelerometer.
- Used Libraries
- Final considerations
This example uses few essential libraries:
This library is dedicated to integrated LEDs.
It exposes T_Led type, which instances are declared:
T_Led rLed, bLed, gLed;
In the void setup() function, LEDs are initialized using static fields offered by T_Led:
LEDs are suddenly turned off with simple method offered by T_Led class:
T_Led class offers also a method to light on the LEDs:
This library, provides few classes usefull when data from integrated IMU is needed. In this article we’ll look at T_ACC and T_AccData.
In this sketch, we declared:
By having a T_ACC object we can ask him for the 3 axis data:
returns a T_AccData object containing the last three measured accelerations in each axis.
T_AccData type has three fields, accData.x, accData.y, accData.z. Each one of this fields contains acceleration value in milliG.
To refresh data we have to analyse the next library.
Sensors’ data are automatically updated by the underlying firmware.
We can use this data to determine if an acceleration is greater than 5 m/s² and light up the LED color related to that axis.
As we learned in the tactigon_IMU.h paragraph, by calling accMeter.getAxis() we get the X,Y and Z acceleration values gathered in this loop iteration.
We can so use the accData.x, accData.y, accData.z fields to compare this value with our threshold of 5 m/s².
Since we don’t care about orientation but only direction, we use abs() function to get absolute value of this acceleration.
if(abs(accData.x) > 5)
This simple sketch is only the first step towards a Gesture Monitor with The Tactigon. In next articles we’ll learn how to use other integrated devices as Bluetooth Low Energy, Gyroscope, Magnetometer, Temperature Sensor and Pressure Sensor, and communicate with Android Application created in Processing.
Stay tuned for more Tactigon’s code!