Hi end up with this
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int Relay[]={0,3,4,5,6,7,8,9,13};
int value;
int protocole;
String sensorID;
String state;
String activate;
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
for(byte i=1; i<9; i++)
{
pinMode(Relay[i], OUTPUT);
}
}
void loop() {
if (mySwitch.available()) {
value = mySwitch.getReceivedValue();
protocole =mySwitch.getReceivedProtocol();
String code = String(value);
activate = code.substring(0,2);
if ((activate == "99") && (protocole == 1)){
int length = code.length();
sensorID = code.substring(2,length-1);
state = code.substring(length-1);
if (state == "1"){
int test = sensorID.toInt();
digitalWrite(Relay[test], HIGH);
}
else if (state == "0"){
int test = sensorID.toInt();
digitalWrite(Relay[test], LOW);
}
delay(500);
mySwitch.resetAvailable();
}
}
}