   return 100000 / num;
 }
 
+int irSensorPin = 2;
+int irLED = 3;
+
 int IR()
 {
-  int num = sonsor_reading(2);
+  int num = irRead(irSensorPin, irLED);
   return num;
 }
 

  Serial.print(nSerial);
  Serial.print(" ");
  Serial.println(command);
}

int sonsor_reading(int pin)

        if(IR())
          delay(1000);
        else
          delay(light() * rand() % 2000);
    }
            
}

void setup()
{
  pinMode(irSensorPin, INPUT);
  pinMode(irLED, OUTPUT);

  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
