Make something happen on a continous input just once and for a specific amount o

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.

nunzzzzzz:
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.

Show us the code for the simplified version. Have you tried debugging the code with "Serial.write" and "Serial.println" added to the code? The approach to any complex project is to break it into simple parts in separate programs and get them working first, and then begin to combine, one at a time and debug that set.

Paul

nunzzzzzz:
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.

My interpretation is something like this - am I correct?

The PC sends a character - pehaps 'A' - and the Arduino does something. If the PC sends another 'A' it does nothing.
If the PC sends (say) 'B' the Arduino will do a different thing, and then it won't responde to more 'B's but it would respond to an 'A'

If I am correct that should be straightforward to implement with something like

if (newChar == previousChar) {
   // do nothing
}
else {
   previousChar = newChar;
   // do whatever newChar signifies
}

...R
Serial Input Basics

Robin, I think all he has is a Fritzing diagram. No code written or tested.

Paul