control using serial port
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 15 Dec 2014 19:50:11 +0000 (20:50 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 15 Dec 2014 19:52:24 +0000 (20:52 +0100)
.gitmodules
libraries/AccelStepper [new submodule]
light_sockets/light_sockets.ino

index 09fdeea..50c4ad7 100644 (file)
@@ -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 (submodule)
index 0000000..f5fdb90
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit f5fdb90f0c33a191442877a6182f8034e37dc812
index 67b957a..3d48c9e 100644 (file)
@@ -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);
+    }
+  }
 }