Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Overview

This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple gesture controller. A nice gesture controller tutorial to start coding with The Tactigon!

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

This example uses few essential libraries:

  • tactigon_led.h
  • tactigon_IMU.h

tactigon_led.h

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:

rLed.init(T_Led::RED);
gLed.init(T_Led::GREEN);
bLed.init(T_Led::BLUE);

LEDs are suddenly turned off with simple method offered by T_Led class:

rLed.off();
gLed.off();
bLed.off();

T_Led class offers also a method to light on the LEDs:

rLed.on();
gLed.on();
bLed.on();

tactigon_IMU.h

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:

T_ACC
accMeter;
T_AccData
accData;

By having a T_ACC object we can ask him for the 3 axis data:

The method:

accMeter.getAxis();

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.

Loop()

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.

X Axis (same applies to Y and Z):

if(abs(accData.x) > 5)
rLed.on();
else
rLed.off();

Final Considerations – Gesture Controller Tutorial

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!

Comments are closed.