Help in code for integrating ir sensor?

Hi,

I am on a project, where I would have one ir sensor with digital output at one place, where after the program starts, if it triggers for the first time, it should do certain actions like( turning motor1 on), and if it triggers for the second time ( motor2 should turn on), how would you code this in arduino, and I am ready to use two ir sensors for convenience, even then I am stuck on handling this issue.

Thanks

Write a short program to make a single LED turn on when a single sensor is triggered.

When that works, extend it so it turns off the LED when the sensor is triggered a second time.

When that works you will have a variable with a value that can be used to decide whether the motor should be running or stationary.

...R

Thanks man,

From your explanation I got one idea namely debounce, it is the one which I was searching for, Anyways, Let God reward you