From: Dobrica Pavlinusic Date: Mon, 15 Dec 2014 19:50:11 +0000 (+0100) Subject: control using serial port X-Git-Url: http://git.rot13.org/?p=Arduino;a=commitdiff_plain;h=afd9ac9d1c841fadf0825afd6e1a8ead91ded8a0 control using serial port --- diff --git a/.gitmodules b/.gitmodules index 09fdeea..50c4ad7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "libraries/AFMotor"] path = libraries/AFMotor url = https://github.com/adafruit/Adafruit-Motor-Shield-library.git +[submodule "libraries/AccelStepper"] + path = libraries/AccelStepper + url = https://github.com/adafruit/AccelStepper diff --git a/libraries/AccelStepper b/libraries/AccelStepper new file mode 160000 index 0000000..f5fdb90 --- /dev/null +++ b/libraries/AccelStepper @@ -0,0 +1 @@ +Subproject commit f5fdb90f0c33a191442877a6182f8034e37dc812 diff --git a/light_sockets/light_sockets.ino b/light_sockets/light_sockets.ino index 67b957a..3d48c9e 100644 --- a/light_sockets/light_sockets.ino +++ b/light_sockets/light_sockets.ino @@ -1,16 +1,28 @@ #define TX_PIN 7 #define LED_PIN 13 -char *code = "1000100110110000000000010"; -//char *code = "1011001001011111000000010"; +/* +codes for my light sockets: + +1000100110110000000000010 +1011001001011111000000010 + +sniffed with rtl-sdr +*/ void setup() { pinMode(LED_PIN, OUTPUT); pinMode(TX_PIN, OUTPUT); + + Serial.begin(9600); + Serial.println("1 or 2 to turn light sockets"); } -void loop() { +void send(char *code) { + Serial.print("send "); + Serial.println(code); + // we have to send same signal at least two times for(int repeat = 0; repeat < 5; repeat++ ) { @@ -32,6 +44,19 @@ void loop() { delayMicroseconds(2000); // guess } - digitalWrite(LED_PIN, LOW); - delay(3000); + digitalWrite(LED_PIN, LOW); +} + +void loop() { + if(Serial.available()) { + int in = Serial.read(); + if (in == '1') { + send("1000100110110000000000010"); + } else if (in == '2') { + send("1011001001011111000000010"); + } else { + Serial.print("ignored "); + Serial.println(in); + } + } }