Problem with digital input

Hi, I'm new in Arduino and i've a little problem in programmation... I use an optical sensor that give me a digital input and i would like to know how can i write the programm to have a 5v output each 3 digital input of the sensor...

Regards

KinoLab

Are you saying you want one output pulse for every three input pulses?

for (int i = 0; i < 3; ++i) {
   // Wait for input to go HIGH
   while (digitalRead (inputPin) == LOW)) {
   }
   // Wait for input to go LOW
   while (digitalRead (inputPin) == HIGH)) {
   } 
}
digitalWrite (outputPin, HIGH);
delay (OUTPUT_PULSE_LENGTH);
digitalWrite (outputPin, LOW);

That's great.... This is what i'm looking for...... ;) :)

Just one thing...

Can i said to let the output HIGH until the next cycle of: for(...etc..) or I can only play with different delay ?

The delay was just there because I thought you wanted a pulse.
If you want it to go low again only after a new input:

for (int i = 0; i < 3; ++i) {
   // Wait for input to go HIGH
   while (digitalRead (inputPin) == LOW)) {
   }
   digitalWrite (outputPin, LOW);
   // Wait for input to go LOW
   while (digitalRead (inputPin) == HIGH)) {
   }
}

and remove the delay and the final “digitalWrite”

Ok… thanks a lot…

Regards

KinoLab