 
 void writeSensors(byte* ptr){
   writeSwitch(ptr);
+  readSensors(ptr);
+
 }
 
 void readTemp(byte* ptr){

  byte *ptr = &command[0];
  uint8_t pipenum = 0;
  if ( radio.available(&pipenum))
    {
     
      bool done = false;
      while (!done)
      {
        done = radio.read( ptr, sizeof(byte[32]) );
        delay(10);
      }
      if (pipenum==1){
          runCommand(ptr);
      }
      Serial.println(ptr[1]);
      
      radio.stopListening();
      radio.write(ptr, sizeof(byte[32]));
      radio.startListening();
    }
    
  
}
void runCommand(byte *ptr)
{
  Serial.println(ptr[0]);
  if(!ptr[0]){
    readSensors(ptr);
  }else{
    writeSensors(ptr);
  }


  if (!isnan(t)){
    ptr[2] = (byte)t;
    ptr[1] = 255;
  }
  else{
    ptr[1] = 13;      
  }


}
void readHum(byte* ptr){
  float h = dht.readHumidity();
  if (!isnan(h)){
    ptr[3] = (byte)h;
    ptr[1] = 255;
  }
  else{
    ptr[1] = 14;      
  }
}
void readLum(byte* ptr){
  ptr[4] = analogRead(lightsSnsorPin);
  ptr[1] = 255;

}

void readSwitch(byte* ptr){
  for(int i = 0; i < sizeof(switchesBytes)-1; i++){
    ptr[switchesBytes[i]]=switchStatus[i];

  }
  ptr[1] = 255;
}

void writeSwitch(byte* ptr){
  for(int i = 0; i < sizeof(switchesBytes)-1; i++){
    digitalWrite(switchsPins[i], ptr[switchesBytes[i]]);
    switchStatus[i] = ptr[switchesBytes[i]];
    ptr[1] = 255;
  }
}



