send signals multiple times - working now
[Arduino] / light_sockets / light_sockets.ino
1 #define TX_PIN 7
2 #define LED_PIN 13
3
4 char *code = "1000100110110000000000010";
5 //char *code = "1011001001011111000000010";
6
7 void setup() {
8    pinMode(LED_PIN, OUTPUT);
9    pinMode(TX_PIN, OUTPUT);
10 }
11
12 void loop() {
13
14   // we have to send same signal at least two times
15   for(int repeat = 0; repeat < 5; repeat++ ) {
16     
17     digitalWrite(LED_PIN, HIGH);
18
19     for(int i = 0; i < strlen(code); i++) {
20       int i1 = 300;
21       int i2 = 900;
22       if (code[i] == '1' ) {
23         i1 = 900;
24         i2 = 300;
25       }
26       digitalWrite(TX_PIN, HIGH);
27       delayMicroseconds(i1);
28       digitalWrite(TX_PIN, LOW);
29       delayMicroseconds(i2);
30     }
31
32     delayMicroseconds(2000); // guess
33   }
34
35   digitalWrite(LED_PIN, LOW);  
36   delay(3000);
37 }