clean serial output
[Arduino] / rpi_promini / rpi_promini.ino
index 9540542..81964a3 100644 (file)
@@ -86,6 +86,7 @@ void setup() {
   Serial.begin(9600);
   mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2  
   mySwitch.enableTransmit(10); // with sender wired in receiving doesn't work, pin #10
+  mySwitch.setRepeatTransmit(repeat); // or change to be different for 433 and 315 MHz
 
   // DS18B20
   sensors.begin();
@@ -153,7 +154,7 @@ void loop() {
        Serial.println(dht.getStatusString());
      }
 
-     if ( input >= 0x30 && input <= 0x39 ) {
+     if ( input >= 0x30 && input <= 0x39 && serial_pos < 2 ) {
        input = input - 0x30; // ASCII to number
        serial_data[serial_pos++] = input;
      } else {     
@@ -189,6 +190,26 @@ void loop() {
            on  ? mySwitch.send("001111110000000011000000")
                : mySwitch.send("001111110000000000000000");
            break;
+         case 5:
+/*
+               cca. 320Mhz 4 channel 4.8A 220V relay
+
+               A       1101001010011010011100010
+               B       1101001010011010011101000
+               C       1101001010011010011100100
+               D       1101001010011010011110000
+               off     1101001010011010011111000
+               on      1101001010011010011100110
+*/
+               switch ( on ) {
+                       case '0': send_315( "1101001010011010011111000" );
+                       case '1': send_315( "1101001010011010011100110" );
+                       case 'A': send_315( "1101001010011010011100010" );
+                       case 'B': send_315( "1101001010011010011101000" );
+                       case 'C': send_315( "1101001010011010011100100" );
+                       case 'D': send_315( "1101001010011010011110000" );
+                       default:  Serial.println("# ERROR: use 0-off 1-on A B C D");
+               }
          default:
            Serial.print("# invalid switch number ");
            Serial.println(serial_data[0], DEC);