title: My Motor is really slow on Arduino
body: <pre><code>int motorPin1 = 8;
  int motorPin2 = 9;
  int motorPin3 = 10;
  int motorPin4 = 11;
  int delayTime = 2;
  char myCol[20];
  
  void setup() {
    Serial.begin (9600);
    pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);
    pinMode(motorPin3, OUTPUT);
    pinMode(motorPin4, OUTPUT);
  }
  
  
  void loop() {
    int lf = 1;
    Serial.readBytesUntil(lf, myCol, 1);
    if (strcmp(myCol, "p") == 0)
    {
      Play();
    }
    if (strcmp(myCol, "s") == 0)
    {
      Stop();
    }
  }
  
  
  
  void Play()
  {
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, HIGH);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
    delay(delayTime);
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, HIGH);
    digitalWrite(motorPin3, HIGH);
    digitalWrite(motorPin4, LOW);
    delay(delayTime);
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, HIGH);
    digitalWrite(motorPin4, HIGH);
    delay(delayTime);
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, HIGH);
    delay(delayTime);
  }
  
  void Stop()
  {
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
  }
  </code></pre>
  
  <p>////////////////////////////////////////////////////</p>
  
  <pre><code>    using UnityEngine;
      using System.Collections;
      using System.IO.Ports;
      using System.Threading;
  
      public class Sending : MonoBehaviour {
  
      //public static SerialPort sp = new SerialPort("COM4", 9600, Parity.None, 8,       StopBits.One);
      public static SerialPort sp = new SerialPort("COM3", 9600);
  
      void Start () {
          OpenConnection();
      }
  
  
  
      public void OpenConnection() 
      {
         if (sp != null) 
         {
           if (sp.IsOpen) 
           {
            sp.Close();
              }
          else 
           {
            sp.Open();   
           }
         }
      }
  
      void OnApplicationQuit() 
      {
         sp.Close();
      }
  
      public static void play(){
          sp.Write("p");
      }
  
  
      public static void stop(){
          sp.Write("s");
      }
  }
  </code></pre>
  
  <p>//////////////////////////////////////////</p>
  
  <pre><code>    using UnityEngine;
      using System.Collections;
  
      public class Play : MonoBehaviour {
  
      // Use this for initialization
      void Start () {
  
      }
  
      // Update is called once per frame
      void Update () {
  
      }
  
      void OnMouseDown() {
          Sending.play();
       }
  
  }
  </code></pre>
  
  <p>//////////////////////////////////////////////////////</p>
  
  <pre><code>    using UnityEngine;
      using System.Collections;
  
      public class Stop : MonoBehaviour {
  
  
      void OnMouseDown()
      {
          Sending.stop();
      }
  
  }
  </code></pre>
  
  <p>/////////////////////////////////////////////////</p>
  
  <p>Hi, i have this code in my arduino and unity, i command it from unity with a play and stop button, but when i press my play button , the motor run but reaaaaally slowly like a step, 1/2 second then another step ..... Can someone please help me?</p>
  
  <p>Thank you </p>