title: Can you run a function multiple times at the same time with Arduino Uno (c code)?
body: <p>I have eight LEDs, four red ones and four yellow ones.
  There is one button for both rows.
  When you push a button, a row of LEDs gets a pulse.
  That means they light up in a row in 0.1 second intervals.
  My question is now: Can I send a pulse while another one is still being processed?
  At the moment a function is called in which a for loop sets the state of the LEDs to HIGH and low, but I can not run it again, before it is finished.</p>
  
  <pre><code>void setup()
  {
    pinMode(0, OUTPUT);
    pinMode(1, OUTPUT);
    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    pinMode(11, OUTPUT);
    pinMode(12, INPUT);
    pinMode(13, INPUT);
    Serial.begin(9600);
  }
  boolean wait(unsigned int j, unsigned int time) &lt;-- test if 0.1 seconds have passed
  { 
    if (millis()&gt;=time+j){
      return true;
    }
    else return false;
  }
  void pulse(int start)
  {
      for(int j = start;j &lt; start + 4;j++)
      {
        digitalWrite(j, HIGH);
        unsigned int time = millis();
       while(wait(100, time)==false){};
       digitalWrite(j, LOW);
      }
  }
  void loop()
  {
    if (digitalRead(12) == HIGH)
    {
      Serial.println("yellow");
      pulse(2);                   &lt;-- I have to wait for this function
    }
    if (digitalRead(11) == HIGH)
    {
      Serial.println("red");
      pulse(6);                   &lt;-- I have to wait for this function
    }
  }
  </code></pre>