Make something happen on a continous input just once and for a specific amount of time My project is very complicated, but here is a visual synthesis 



The input actually comes from a kinect, that detects a person position through Processing, which I connected via Serial to Arduino.
Whenever my trigger is activated, a character is sent to arduino.
What I need to make everything work properly is, upon the said input, some lines of code have to be executed once and for a specific amount of time. And upon repeated input, these lines must not be executed until the input changes.

A semplified version would be: I press a button, led turns on for one second and then turns off (even if i'm still pressing it). led doesn't turn on again until i stop pressing and press again. Obviously in my project the input is the character received via serial and the output is the motor to turn on for some time, and then turn off.

I wanted to make the serial thing specific because i think it makes the thing a little bit trickier than the led example.
you want something along the lines:

bool continuing;
#define trigger 't'
void loop(){
  if( Serial.avaiable()) { 
    char c;
    c=Serial.read();
    if (continuing) { 
       if (c==trigger) { //do nothing, ignore it
       } else { 
       continuing=False; }
   } else { 
     continuing=True;
     motors.start();
     the_time=milis();
   }
 };
 if (the_time+timespan&gt;milis()) {motors.stop();};
}