Arduino Simple Hand Motion V1


Introduction: Arduino Simple Hand Motion V1

Arduino simple hand motion.
Detect hand motion direction and speed.
Can be used to control any device... I let you the magic  imagination 

You will need:
-1 *Arduino (Uno)
-3 or 5 or ... IR switch ( I used E18D80NK)  ( 6€ )
-3* 1k resistors
- 3* LEDs. 

The code :
#define sIRA 10
#define sIRB 8
#define sIRC 9

#define LED1 3
#define LED2 4
#define LED3 5
char orders[3] = {'0','0','0'};
int indexOrder = 0;
//speed of detection Ms
int Captspeed = 1;

long tA;
long tB;
long tC;

void setup() {
  Serial.begin (9600);
  for(int i = 8;i<=10;i++)
     pinMode(i, INPUT); 
for(int i = 3;i<=5;i++)
     pinMode(i, OUTPUT);
void loop() {
  //Reset Command after 800 Msecond
   if(millis()%1000 > 800)
  //If we have 3 signals , Calculate Command
  if(tA > 0 && tB> 0 && tC>0)
       int command =  CalculateCommand();
       if(command <=0)
  //check for sensors
   if(indexOrder > 2)
     indexOrder = 0;
   int vA =  digitalRead(sIRA);
   if(tA == 0 && vA == 0) tA = millis();
   int vB =  digitalRead(sIRB);
   if(tB == 0 && vB == 0) tB = millis();
   int vC =  digitalRead(sIRC);
   if(tC==0 && vC == 0) tC = millis();
   //Stop Command
    if(vA == 0 && vB == 0 && vC == 0 )
     // DoCommand(0);
int CalculateCommand(void)
   Serial.print("tA = ");
   Serial.print("tB = ");
   Serial.print("tC = ");
     if((tA <= tB) && tA <= tC)
         return -3 ;// FORWRD
     if((tB <= tC) && tB <= tA)
         return -2 ;// LEFT
     if((tC <= tB) && tC <= tA)
         return -1 ;//RIGHT 
   return 1;


void  DoCommand(int command)
   switch (command)
     case 0: Serial.println("Stopped");delay(500);break;
     case -1: Serial.println("Turn RIGHT ");digitalWrite(LED1,HIGH); delay(1000);break;
     case -2: Serial.println("Turn LEFT ");digitalWrite(LED2,HIGH); delay(1000);break;
     case -3: Serial.println("GO FORWARD ");digitalWrite(LED3,HIGH); delay(1000);break;
     case -4: Serial.println(" GO BACK "); delay(1000);break;
    default : Serial.println("NO Command detected");break;
void    ResetCommand()
   for(int i = 3;i<=5;i++)
       digitalWrite(i,LOW);//ALL LEDs
   tA = 0;//Reset time A
   tB = 0;//Reset time B
   tC = 0;//Reset time C



    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest

    6 Discussions

    Simple and elegant project. Good work.

    Can you just add a new picture showing detailed layout and electriical connections. Thanks.

    I'm sure it's just a Rookie/Amateur mistake on my part :S


    2013 16:46.jpg

    Hey affiaymen,
    amazing instructable, just what I've searched for all over the net and your/this instructable is very practical. I haven't had much experience with arduino and have relatively basic experience in electronics and have hit a wall trying to get this set up to work, maybe you can see what/where my problem lies? On the IR sensors (same ones as you used) I understand pinout as follows:- RED/Power, BLACK/Gnd, YELLOW/Signal. I've all 3 x REDS tinned together and soldered onto 1 x male header pin (1K resistor in line on each of 3 wires). I've all 3 x BLACKS tinned together and soldered onto 1 x male header pin. I have each YELLOW tinned separately and soldered on to separate male pin each of their own. LED's have all BLACKS tinned together and soldered onto 1 x male header pin, each RED wire from LED's are tinned separately and soldered onto separate male header pin off their own. I'm not entirely sure where to locate my GND's from IR LED's and regular LED's and also where to put RED/pwr from IR LED's on Arduino UNO. See photo for better understanding, thank you very much if you are able to have the time to read this and have a look :)

    Hi Saterk,
    Im actually I'm using it now for commanding my tv.. So no need to change channel and volume with remote ...:)
    In your case you can attach it to a servo and play with frequency you can ovoid obstacle .
    I'm trying always to make quit simple construct with minimum of components.
    I will notify you for my next video , how to hack a simple IR switch (6€) and use it as distance range sensor (30€) with almost nada!! ;)

    When reading the title I was expecting something with an accelerometer, but this is elegant and simple, and embedded in some kind if "artefact" or magical device this could be really cool.

    I wonder... One of my many ideas (on ice) was a hammer that would light up when it hit something (or, for the sake of not destroying things, when it came close). I was thinking of using an accelerometer for that, but maybe I could use your approach...

    Thanks for sharing!