/* Arduino light control of Nexa and Everflourish RF 433.92 MHz based systems. For details, see: http://hblok.net http://hblok.net/blog/posts/tag/433 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include Light switches[] = { {}, // main {EVERFLOURISH, {0x4E, 0x18, 0x60}, {0x4E, 0x18, 0x6F}}, // A {EVERFLOURISH, {0x4E, 0x1B, 0x40}, {0x4E, 0x1B, 0x4F}}, // B {EVERFLOURISH, {0x4E, 0x1A, 0xC0}, {0x4E, 0x1A, 0xCF}}, // C {EVERFLOURISH, {0x4E, 0x19, 0x90}, {0x4E, 0x19, 0x9F}}, // D // nexa {NEXA, {0x23, 0xF3, 0xED, 0x80}, {0x23, 0xF3, 0xED, 0x90}}, // E {NEXA, {0x23, 0xF3, 0xED, 0x81}, {0x23, 0xF3, 0xED, 0x91}}, // F {NEXA, {0x23, 0xF3, 0xED, 0x82}, {0x23, 0xF3, 0xED, 0x92}}, // G }; int clickCount = 0; bool serialOut = true; void setup() { set_out_pin(2); // Set pin RF sender is connected to. Serial.begin(9600); Serial.println("setup"); } void loop() { if (Serial.available() > 1) { int light_id = Serial.read() - 'A' + 1; int on = Serial.read() - '0'; if(serialOut) { Serial.print(light_id); Serial.println(on); clickCount++; if(clickCount > 20) { serialOut = false; } } if (light_id < 0 || light_id > 12 || on < 0 || on > 1) { return; } for(int i=0; i < 4; i++) { send(switches[light_id], on ? ON : OFF); delay(80); } } }