X-Git-Url: http://git.rot13.org//?p=Arduino;a=blobdiff_plain;f=light_sockets%2Flight_sockets.ino;fp=light_sockets%2Flight_sockets.ino;h=85818e059b07cc7582448f10073953e20ebb5f8c;hp=3d48c9e49b8e12364b7b5e3d8f8b489165a641a9;hb=d32321c95447131331685af0bab69f9ca99c9d25;hpb=afd9ac9d1c841fadf0825afd6e1a8ead91ded8a0;ds=sidebyside diff --git a/light_sockets/light_sockets.ino b/light_sockets/light_sockets.ino index 3d48c9e..85818e0 100644 --- a/light_sockets/light_sockets.ino +++ b/light_sockets/light_sockets.ino @@ -10,12 +10,21 @@ codes for my light sockets: sniffed with rtl-sdr */ +int int_0 = 300; // ms +int int_1 = 900; // ms +int wait = 2000; // ms +int repeat = 5; // times + void setup() { pinMode(LED_PIN, OUTPUT); pinMode(TX_PIN, OUTPUT); Serial.begin(9600); Serial.println("1 or 2 to turn light sockets"); + Serial.println("q/a - 0 inteval +/- 100 ms"); + Serial.println("w/s - 1 inteval +/- 100 ms"); + Serial.println("e/d - wait +/- 100 ms"); + Serial.println("r/f - repeat +/- 1"); } @@ -24,16 +33,16 @@ void send(char *code) { Serial.println(code); // we have to send same signal at least two times - for(int repeat = 0; repeat < 5; repeat++ ) { + for(int r = 0; r < repeat; r++ ) { digitalWrite(LED_PIN, HIGH); for(int i = 0; i < strlen(code); i++) { - int i1 = 300; - int i2 = 900; + int i1 = int_0; + int i2 = int_1; if (code[i] == '1' ) { - i1 = 900; - i2 = 300; + i1 = int_1; + i2 = int_0; } digitalWrite(TX_PIN, HIGH); delayMicroseconds(i1); @@ -41,7 +50,7 @@ void send(char *code) { delayMicroseconds(i2); } - delayMicroseconds(2000); // guess + delayMicroseconds(wait); // guess } digitalWrite(LED_PIN, LOW); @@ -54,6 +63,43 @@ void loop() { send("1000100110110000000000010"); } else if (in == '2') { send("1011001001011111000000010"); + + } else if (in == 'q') { + int_0 += 100; + Serial.print("inteval 0 = "); + Serial.println(int_0); + } else if (in == 'a') { + int_0 -= 100; + Serial.print("inteval 0 = "); + Serial.println(int_0); + + } else if (in == 'w') { + int_1 += 100; + Serial.print("inteval 1 = "); + Serial.println(int_1); + } else if (in == 's') { + int_1 -= 100; + Serial.print("inteval 1 = "); + Serial.println(int_1); + + } else if (in == 'e') { + wait += 100; + Serial.print("wait = "); + Serial.println(wait); + } else if (in == 'd') { + wait -= 100; + Serial.print("wait = "); + Serial.println(wait); + + } else if (in == 'r') { + repeat += 1; + Serial.print("repeat = "); + Serial.println(repeat); + } else if (in == 'f') { + repeat -= 1; + Serial.print("repeat = "); + Serial.println(repeat); + } else { Serial.print("ignored "); Serial.println(in);