#include #include RCSwitch rcswitch = RCSwitch(); void setup() { Serial.begin(9600); //timeout for Serial.find(), Serial.setTimeout(100); rcswitch.enableTransmit(4); Serial.println("ardvindo started"); } void loop() { if(Serial.available() > 0) { // - 'i' info for identification // - 'e' enable / switch on // - 'd' disable / switch off char command = Serial.read(); if(command == 'i') { Serial.println("ardvindo"); } else if(command == 'e' || command == 'd') { //wait for space and family while(Serial.available() < 2) { delay(1); } Serial.read(); //space char family = Serial.read(); int group = Serial.parseInt(); int device = Serial.parseInt(); if(command == 'e') { rcswitch.switchOn(family, group, device); } else { rcswitch.switchOff(family, group, device); } Serial << command << " " << family << " " << group << " " << device << "\n"; } // strip all further chars until end of line Serial.find("\n"); } }