-
-
Save vsg24/4b1f5142ca099f76903c093b1745a3de to your computer and use it in GitHub Desktop.
rc switch send+receive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example for receiving | |
https://github.com/sui77/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(115200); | |
mySwitch.enableReceive(4); // Receiver on interrupt 0 => that is pin #2 (for UNO) | |
} | |
void loop() { | |
if (mySwitch.available()) { | |
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); | |
mySwitch.resetAvailable(); | |
} | |
} | |
/* | |
char a = "100100010011000011000001"; // pulse length 352, protocol 1 | |
char b = "100100010011000011000010"; // pulse length 352, protocol 1 | |
char c = "100100010011000011000100"; // pulse length 352, protocol 1 | |
char d = "100100010011000011001000"; // pulse length 352, protocol 1 | |
void setup() { | |
Serial.begin(9600); | |
// Transmitter is connected to Arduino Pin #10 | |
mySwitch.enableTransmit(10); | |
// Optional set pulse length. | |
mySwitch.setPulseLength(REPLACE_WITH_YOUR_PULSE_LENGTH); | |
// Optional set protocol (default is 1, will work for most outlets) | |
mySwitch.setProtocol(REPLACE_WITH_YOUR_PROTOCOL); | |
// Optional set number of transmission repetitions. | |
// mySwitch.setRepeatTransmit(15); | |
} | |
void loop() { | |
// Binary code - button 3 | |
mySwitch.send("000101010101000101010101"); | |
delay(1000); | |
mySwitch.send("000101010101000101010100"); | |
delay(1000); | |
// Binary code - button 4 | |
mySwitch.send("000101010101010001010101"); | |
delay(1000); | |
mySwitch.send("000101010101010001010100"); | |
delay(1000); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment