5 codes for my light sockets:
7 1000100110110000000000010
8 1011001001011111000000010
14 pinMode(LED_PIN, OUTPUT);
15 pinMode(TX_PIN, OUTPUT);
18 Serial.println("1 or 2 to turn light sockets");
22 void send(char *code) {
23 Serial.print("send ");
26 // we have to send same signal at least two times
27 for(int repeat = 0; repeat < 5; repeat++ ) {
29 digitalWrite(LED_PIN, HIGH);
31 for(int i = 0; i < strlen(code); i++) {
34 if (code[i] == '1' ) {
38 digitalWrite(TX_PIN, HIGH);
39 delayMicroseconds(i1);
40 digitalWrite(TX_PIN, LOW);
41 delayMicroseconds(i2);
44 delayMicroseconds(2000); // guess
47 digitalWrite(LED_PIN, LOW);
51 if(Serial.available()) {
52 int in = Serial.read();
54 send("1000100110110000000000010");
55 } else if (in == '2') {
56 send("1011001001011111000000010");
58 Serial.print("ignored ");