Introduction: Automate Your Home by Your Finger's Movements


In this project we will control our home just with different finger's movement, you have just to move your finger and do what ever you want

this instructable is very useful for lazy people ;) .

Step 1: Wath You Need ...

First this project is divided by two part an Controller side and an Application part

Controller side:

- Accelerometer (GY-271 HMC5883L)

- Arduino Uno (or any other Arduino)

Application part: (for one relay circuit)

- One relay (with respecting the terms of its use)

- BC546 (for 12V relay)

- One Led

Step 2: Controller (Main Idea)

To reach our result ,the Arduino will read the rotation of the finger by the accelerometer and will define different position (Up,Right,Left,Down).

Then , with successive positions the Arduino will deduce a drawing and will compare it to the drawings in the memory to apply the appropriate conditions.

Step 3: Controller (The Circuit)

Connecting the accelerometer to the Arduino:

- Our accelerometer works with the I2C communication so it use the A4 and A5 pins from the Arduino:

  • - Connect the VCC to Arduino's +5V
  • - Connect the GND to Arduino's GND
  • - Connect the SDA pin to Arduino's A4
  • - Connect the SCL pin to Arduino's A5

Step 4: Controller (The Arduino's Code)

To use the accelerometer you need the HMC5883L library

For the Infrared communication you should use this library

I devised my code to few functions :

float getRotation( char x) :

this function get the accelerometer rotation and X variable define witch axis to return.

float getRotation(char x) {float heading;
  sensors_event_t event; 
  mag.getEvent(&event); //read the data from the accelerometer  

	if (x=='x'){heading = atan2(event.magnetic.x, event.magnetic.y);}
        else if (x=='y'){heading = atan2(event.magnetic.y, event.magnetic.z);}
        else if (x=='z'){heading = atan2(event.magnetic.z, event.magnetic.x);}

return heading * 180/M_PI; }

bool Verify( float current[3], float origin[4][3],byte row ) :

this function verify if the accelerometer is in a specific position by comparing the read data stocked in the array 'current[3]' to the data of the array 'origin[4][3]' this array has 4 rows to each point (in our drawings we have just 4 points) and the variable 'row' set witch row to use .

bool Verify(float current[3], float origin_[4][3],int row){  byte toler=37;//this variable set the tolerance to respect
 //return True if the next conditions are true
  return    origin_[row][0]-toler<=current[0]   &&    
	current[0]<origin_[row][0]+toler &&
	  origin_[row][1]-toler<=current[1]   &&   
	 current[1]<origin_[row][1]+toler &&
	  origin_[row][2]-toler<=current[2]   &&  
	 current[2]<origin_[row][2]+toler ;}

byte getPoint (float origin[4][3] ) :

this functions combine the two last functions and return the accelerometer's position :

(Up(return 1) ,Right(return 2),Down(return 3) ,Left(return 4) )

byte getPoint (float origin__[4][3] ){  byte  return_=0;

float current[3]={getRotation('x'),

if(Verify(current, origin__,0)){return_=1;} 
else if(Verify(current, origin__,1)){return_=2;} 
else if(Verify(current, origin__,2)){return_=3;} 
else if(Verify(current, origin__,3)){return_=4;}

return return_;

bool Compare(byte Mdrawing[4][4],byte row):

this function get the successive points and see if they are in the same order of the points stocked in 'Mdrawing[4][4]' there are 4 raws in this array that depends on how much drawings you've declared , in this we have just 4 drawings

bool Compare (byte Mdrawing[4][4],byte row){ byte Cpoint=getPoint( origin); //read the current point of the accelerometer(origin is a global variable ,it's the rotations of each point )
  byte Ppoint=0;// this variable will stock previous points
  byte y=0;
  byte x=0;
 while(Mdrawing[row][x]!=0 && x<4){x++;}//get the number of columns that the value is different than 0

Cpoint = getPoint( origin);//read the current point

        if (Cpoint==Mdrawing[row][y] && Cpoint!=0){Ppoint=Cpoint;//if the current point is in the same order of the point in 'Mdrawing' 
 		 while (Ppoint==Cpoint && y!=x-1){Cpoint=getPoint(origin);}// wait that the current point change
                    y++;}//pass to the next point 
  	else if(Cpoint!=Mdrawing[row][y] && Cpoint!=0){return 0;}}//if the current point is different than the point in 'Mdrawing' 

return 1;}

float origin[4][3]:

this array contain the rotation of each points you can define it with the calibration file .It looks like:

float origin[4][3]= 
{{71.93,149.56,-29.04},//up point

{5.97,126.75,-82.03},//right point 

{-72.14,162.31,-134.71},//down point

{97.64,-174.11,-52.44}};//left point

byte Mdrawing[4][4]:

this array contain the order that the points should to make a specific drawing for example:(picture 1)

Step 5: Application Circuit

In this circuit i used one relay but you can use more than one in the same Arduino.

Step 6: Final Test

I've moved my finger in those positions to Turn on and Turn off the lamp.


YuriMat (author)2015-08-28

Cool project! You can increase the accuracy of magnetometer measurements after magnetometer calibration. See my instructable about it:

gulliverrr (author)2015-07-02

There are <br> in your code from copy paste from HTML in Step 4. Make sure you dont copy these in the code of arduino (or it won't compile) :) Cool idea btw!!!

seamster (author)2015-06-30

Very cool ideas!