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

#define DHTPIN 2 
#define DHTTYPE DHT11 

RF24 radio(9,10);
DHT dht(DHTPIN, DHTTYPE);

const uint64_t pipes[2] = { 0xF0F0F0F001LL, 0xF0F0F0F002LL };
const byte shortAddr = 0x02;
int switchsPins[] = {13};
int switchesBytes[] = {10};
int switchStatus[] = {0};
void setup(void)
{
  Serial.begin(57600);
  
  dht.begin();
  radio.begin();
  
  radio.setAutoAck(false);
  radio.setRetries(15,15);
  radio.setPALevel(RF24_PA_MAX);
  radio.openReadingPipe(1,pipes[1]);
  radio.openWritingPipe(pipes[0]);
  
  radio.startListening();
  
  // Testing switch on/off
   pinMode(switchsPins[0], OUTPUT);  
 
  
  
}

void loop(void)

  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;
  }
}



