title: Sending RF signal after Serial input
body: <p>I am trying to reproduce a simple 433mhz signal through an RF transmitter.  I have used RCSwitch to capture this signal and when I write a simple "Send" code, it works great - it turns off a light via a wireless outlet.  My issue is not really related to this hack.  </p>
  
  <p>If I use this code below, my signal comes out correctly.</p>
  
  <pre><code>  #include &lt;RCSwitch.h&gt;
  
  RCSwitch mySwitch = RCSwitch();
  
  void setup() {
    mySwitch.enableTransmit(3);
     mySwitch.setPulseLength(183);
     mySwitch.setRepeatTransmit(6);
  }
  
  void loop() {
    mySwitch.send(5526835, 24);
    delay(5000);    
  }
  </code></pre>
  
  <p>However, when I try to do something more complicated with this code using the serial input, my signal does not work.  As far as I can tell, the pulseLength gets set to 350 instead of my required 183.  </p>
  
  <p>My code is a little longs, so I will not post, but I am asking for an input from the Serial.  A "11" means device 1 ON and a "10" means device 1 OFF.   The code seems to work as expected and even gives an output signal, but the pulse length goes back to 350.  Is there something going on with an "interrupt" or is the Serial input doing something to my output signal?  I have even played around with interrupts but still cannot get this more complicated example to work.</p>
  
  <p>EDIT: -  code to ask for what device</p>
  
  <pre><code>#include &lt;RCSwitch.h&gt;
  RCSwitch mySwitch = RCSwitch();
  
  int inputData; int signalInt = 0;
  
  void setup() {
     Serial.begin(9600);
     mySwitch.enableTransmit(3);
     mySwitch.setPulseLength(183);
     mySwitch.setProtocol(1);
     mySwitch.setRepeatTransmit(6);
  }
  void loop(){
    Serial.println("Enter Device ID Integer:");
    startProcess();
  }
  
  void startProcess(){
    while (Serial.available() &gt; 0){
      inputData = Serial.parseInt();
      convertToDevice(inputData);
    } 
    startProcess();  
  }
  
  void convertToDevice(int input){
      String x = String(input);
      toggleDevice(x.charAt(0), x.charAt(1));
  }
  
  void toggleDevice(char deviceId, char sig){
     signalInt = 0;
     delay(2000); //only here to see if this helped
     if(deviceId == '1'){
         if(sig == '0'){ // device off  
            mySwitch.send(5526844, 24); 
            delay(2000);
            startProcess();
          }
          if(sig == '1'){ // device on
             mySwitch.send(5526835, 24);
             delay(2000);
  
            startProcess();
          }
      } // end device 1
      if(signalInt == 0){
        Serial.println('Nope, wrong code');
        startProcess();
      }
  
  }
  </code></pre>