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€ )
-wires.
-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)
    ResetCommand(); 
  //If we have 3 signals , Calculate Command
  if(tA > 0 && tB> 0 && tC>0)
   {
       int command =  CalculateCommand();
       if(command <=0)
          DoCommand(command);
   }
  //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);
    } 
   delay(Captspeed); 
}
int CalculateCommand(void)
{
   Serial.print("tA = ");
   Serial.println(tA);  
   Serial.print("tB = ");
   Serial.println(tB);  
   Serial.print("tC = ");
   Serial.println(tC);
   delay(1);
  
     if((tA <= tB) && tA <= tC)
         return -3 ;// FORWRD
     if((tB <= tC) && tB <= tA)
         return -2 ;// LEFT
     if((tC <= tB) && tC <= tA)
         return -1 ;//RIGHT 
  //Etc
   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;
   }
    ResetCommand();
}
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
}