This repository has been archived on 2024-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
trev/arduino/src/sketch.ino

41 lines
681 B
C++

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int mode = 0;
boolean on = false;
void setup()
{
Serial.begin(9600);
mySwitch.enableTransmit(3);
}
void loop()
{
if(Serial.available()) {
mode = Serial.read();
switch (mode) {
case 126:
if(on) {
controlRCOutlets("0FFF0FFF0000");
Serial.println("Light is off.");
on = false;
} else {
controlRCOutlets("0FFF0FFF000F");
Serial.println("Light is on.");
on = true;
}
break;
}
}
}
void controlRCOutlets(const char* sCodeWord) {
mySwitch.sendTriState(sCodeWord);
delay(1000);
}