title: Arduino port gets stuck on
body: <p>I am trying to create a pattern that will turn one of the Arduinos ports on and off. However, after about 2 on/offs it gets stuck on and won't turn off unless I unplug the Arduino. I have tried many solutions such as trying to set the int to 0 after it sends power to the port. Here is my code for the server side and for the arduino side:</p>
  
  <p>Arduino Code:</p>
  
  <pre><code>int Relay = 13;
  //The pin that the relay is attached to
  //int time;
  //Creates temp variable
  
  void setup() {
      Serial.begin(9600);
      pinMode(Relay, OUTPUT);
  }
  
  void loop() {
      while(true) {
          //Check if data has been sent from the computer:
          if (Serial.available()) {
                int time;
            //Assign serial value to temp
            time = Serial.parseInt();
            //Output value to relay
  
                delay(1000);
                digitalWrite(Relay, HIGH);
            delay(time);
            digitalWrite(Relay, LOW);
          }
      }
  }
  </code></pre>
  
  <p>Server Code:</p>
  
  <pre><code>for(int i = 0; i &lt; 11; i++) {
      out.write("10000".getBytes("UTF-8"));
          out.flush();
          Thread.sleep(1500);
  }
  </code></pre>
  
  <p>If anyone sees anything wrong or sees a solution please let me know.</p>
  
  <p>Thanks :)</p>