37 lines
588 B
C++
37 lines
588 B
C++
#include <RCSwitch.h>
|
|
|
|
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);
|
|
}
|