بالاخر یافتم
sketch_aug02a
int rx = 2;
int key = 3;
int relay = 4;
boolean mode = 0;
void setup()
{
Serial.begin(9600);
Serial.println("setup");
vw_set_rx_pin(rx);
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_rx_start();
pinMode(key, INPUT);
pinMode(relay, OUTPUT);
boolean k = digitalRead(key);
}
void loop()
{
boolean c =!k;
k = digitalRead(key);
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)){
if ((buf[0] == 'r') && (buf[1] == 'e') && (buf[2] == 'z') && (buf[3] == 'a') && (buf[4] == '1') ){
a = !a;
}
}
if (b==c){
a= !a;
}
digitalWrite(relay, a);
}