Created
September 27, 2015 07:14
-
-
Save AgataJot/0d9577d3f0e0e13f5ea4 to your computer and use it in GitHub Desktop.
Arduino code to tx to wireless socket switch
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
#include <RCSwitch.h> | |
RCSwitch mySwitch = RCSwitch(); | |
byte inByte = 0; | |
void setup() { | |
Serial.begin(9600); | |
// Transmitter is connected to Arduino Pin #10 | |
mySwitch.enableTransmit(2); | |
// Optional set pulse length. | |
// mySwitch.setPulseLength(320); | |
// Optional set protocol (default is 1, will work for most outlets) | |
// mySwitch.setProtocol(2); | |
// Optional set number of transmission repetitions. | |
// mySwitch.setRepeatTransmit(15); | |
//Serial.println("Ready"); // Ready to receive commands | |
} | |
void loop() { | |
/* Switch using decimal code */ | |
if(Serial.available() > 0) { // A byte is ready to receive | |
inByte = Serial.read(); | |
if (inByte == '1') { // byte is '1' | |
mySwitch.send(14368527, 24); | |
Serial.println("1 ON"); | |
} | |
else if (inByte == '2') { // byte is '2' | |
mySwitch.send(14368526, 24); | |
Serial.println("1 OFF"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment