Sunday, March 20, 2016

arduino RF-Receiver Code

/* Example for receiving http://code.google.com/p/rc-switch/ If you want to visualize a telegram copy the raw data and paste it into http://test.sui.li/oszi/ */ #include RCSwitch mySwitch = RCSwitch(); int a=0; int relay = 5; void setup() { Serial.begin(9600); mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 } void loop() { if (mySwitch.available()) { a = mySwitch.getReceivedValue(); if(a == 17715){ //Serial.println("Relay ON"); digitalWrite(ledPin, HIGH); } if(a == 17724){ //Serial.println("Relay OFF"); digitalWrite(ledPin, LOW); } mySwitch.resetAvailable(); } }