Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Simple example for receiving
- https://github.com/sui77/rc-switch/
- */
- #include <RCSwitch.h>
- #define relayPin D6
- #define receiverPin D5
- bool switchState = false;
- RCSwitch mySwitch = RCSwitch();
- void setup() {
- Serial.begin(9600);
- pinMode(relayPin,OUTPUT);
- mySwitch.enableReceive(receiverPin); // Receiver on interrupt 0 => that is pin #2
- }
- void loop() {
- if (mySwitch.available()) {
- Serial.print("Received ");
- Serial.print( mySwitch.getReceivedValue() );
- Serial.print(" / ");
- Serial.print( mySwitch.getReceivedBitlength() );
- Serial.print("bit ");
- Serial.print("Protocol: ");
- Serial.println( mySwitch.getReceivedProtocol() );
- if(mySwitch.getReceivedValue() == 5852072)
- {
- digitalWrite(relayPin,HIGH);
- Serial.println("Setting relay");
- delay(300);
- digitalWrite(relayPin,LOW);
- }
- delay(500);
- mySwitch.resetAvailable();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement