From f12026d900790d5248de556c3b548cb95839de79 Mon Sep 17 00:00:00 2001 From: Stefan Sterz Date: Tue, 12 Jan 2016 20:05:43 +0100 Subject: [PATCH] add basic rc switching capability --- .gitignore | 1 + arduino/src/sketch.ino | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/.gitignore b/.gitignore index d3ab2ca..3c988fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ */node_modules/* +arduino/.build/* diff --git a/arduino/src/sketch.ino b/arduino/src/sketch.ino index 9f91418..79b4e48 100644 --- a/arduino/src/sketch.ino +++ b/arduino/src/sketch.ino @@ -1,8 +1,37 @@ +#include + +int incomingByte = 0; +boolean on = false; +RCSwitch mySwitch = RCSwitch(); +int mode = 0; void setup() { + Serial.begin(9600); + mySwitch.enableTransmit(3); } void loop() { + if(Serial.available()) { + incomingByte = Serial.read(); + + switch(mode) + { + case 126: + if(on) { + controlRCOutlets("0FFF0FFF0000"); + on = false; + } else { + controlRCOutlets("0FFF0FFF000F"); + on = true; + } + } + + } +} + +void controlRCOutlets(const char* sCodeWord) { + mySwitch.sendTriState(sCodeWord); + delay(1000); }