Introduction: The Tactigon Accelerometer and LEDs Interaction
This article 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
Step 1: Used Libraries
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.
This library is used in this sketch to be able to use IMU_loop() function.
This function is called each void loop() iteration to refresh IMU data.
Step 2: Loop()
loop() function in this sketch will first of all refresh IMU values by calling IMU_loop() function.
Now that we have updated values from the sensors, we can use them to determine if an acceleration is greater than 500 milliG 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 500millig. Since we don’t care about orientation but only direction, we use abs() function to get absolute value of this acceleration.
X AXIS (SAME APPLIES TO Y AND Z):
if(abs(accData.x) > 500)
Step 3: Final Considerations
This simple sketch is only the first step towards a Gesture Controller 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!
We have a be nice policy.
Please be positive and constructive.