 
 boolean verifyCode()
 {
-  for(byte i=0;i<maxCodeLength;i++)
+  for(int i=0;i<maxCodeLength;i++)
   {
     if(readCode[i] != code[i])
     {
       Serial.println("ZLE");
-      return false;   
-      resetCode();
+      return false; 
     }
-    Serial.println("OK");
+    else
+    {
+      Serial.println("OK");
+    }
   }
-  return check;
-  resetCode();
+resetCode();
+return true;
 }
-
 void grantAccess()
 {    
     digitalWrite(relay2, HIGH);
     delay(2000);
     digitalWrite(relay2, LOW);  
-}
-
+}

{

  Serial.begin(9600);
  radio.initialize(FREQUENCY, MASTERADDRESS, NETWORKADDRESS);
  radio.encrypt(ENCRYPTKEY);
  pinMode(relay1, OUTPUT);


void loop() 
{
  if (radio.receiveDone())
  {
    Serial.print("message [");
    int premenna = 0;
    for (int i = 0; i < radio.DATALEN; i++)
    {
      readCode[i] = (char)radio.DATA[i];
      Serial.print((char)radio.DATA[i]);
    }
    Serial.print("], RSSI ");
    Serial.println(radio.RSSI);
    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.println("Prijata sprava");
      if (verifyCode())grantAccess(); 
    }
  }
}

