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

42 lines
705 B
Arduino
Raw Normal View History

2016-01-12 20:05:43 +01:00
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
2016-01-12 20:05:43 +01:00
int mode = 0;
int incomingByte = 0;
boolean on = false;
2016-01-11 21:09:53 +01:00
void setup()
{
2016-01-12 20:05:43 +01:00
Serial.begin(9600);
mySwitch.enableTransmit(3);
2016-01-11 21:09:53 +01:00
}
void loop()
{
2016-01-12 20:05:43 +01:00
if(Serial.available()) {
incomingByte = Serial.read();
switch (var) {
2016-01-12 20:05:43 +01:00
case 126:
2016-01-12 20:05:43 +01:00
if(on) {
controlRCOutlets("0FFF0FFF0000");
Serial.println("Light is off.");
2016-01-12 20:05:43 +01:00
on = false;
} else {
controlRCOutlets("0FFF0FFF000F");
Serial.println("Light is on.");
2016-01-12 20:05:43 +01:00
on = true;
}
break;
2016-01-12 20:05:43 +01:00
}
}
}
void controlRCOutlets(const char* sCodeWord) {
mySwitch.sendTriState(sCodeWord);
delay(1000);
}