Skip to content

Instantly share code, notes, and snippets.

@pouicr
Created October 12, 2015 12:48
Show Gist options
  • Save pouicr/861817c8f3942212d54c to your computer and use it in GitHub Desktop.
Save pouicr/861817c8f3942212d54c to your computer and use it in GitHub Desktop.
/************************************************* receiver ************************************************/
/*
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.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
mySwitch.resetAvailable();
}
}
/************************************************* transmitter ************************************************/
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
// Optional set pulse length.
mySwitch.setPulseLength(321);
// set protocol (default is 1, will work for most outlets)
// mySwitch.setProtocol(2);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
pinMode(13,OUTPUT);
}
void loop() {
mySwitch.send("100001010001000000001100");
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment