send pulses to 315 MHz module
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 14 Dec 2014 21:42:10 +0000 (22:42 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 14 Dec 2014 21:42:10 +0000 (22:42 +0100)
They seem to look OK on scope, will have to test with real module

light_sockets/light_sockets.ino [new file with mode: 0644]

diff --git a/light_sockets/light_sockets.ino b/light_sockets/light_sockets.ino
new file mode 100644 (file)
index 0000000..9d49fc9
--- /dev/null
@@ -0,0 +1,30 @@
+#define TX_PIN 7
+#define LED_PIN 13
+
+char *code = "1000100110110000000000010";
+//char *code = "1011001001011111000000010";
+
+void setup() {
+   pinMode(LED_PIN, OUTPUT);
+   pinMode(TX_PIN, OUTPUT);
+}
+
+void loop() {
+  digitalWrite(LED_PIN, HIGH);
+
+  for(int i = 0; i < strlen(code); i++) {
+    int i1 = 300;
+    int i2 = 900;
+    if (code[i] == '1' ) {
+      i1 = 900;
+      i2 = 300;
+    }
+    digitalWrite(TX_PIN, HIGH);
+    delayMicroseconds(i1);
+    digitalWrite(TX_PIN, LOW);
+    delayMicroseconds(i2);
+  }
+  
+  digitalWrite(LED_PIN, LOW);  
+  delay(3000);
+}