// basic IR sensor actuates servo without time test
if (IRvalue < 3) { //sensor output went low TRIGGERED
delay (6000); // eliminate redundant triggering ... similar to switch bounce
myservo.writeMicroseconds(1200); // tell servo to go to active position
delay(1200); // wait for the servo to reach the position
myservo.writeMicroseconds(600); // tell servo to return to passive position
delay(100);
count=count+1;// tally event
}
// whats the best approach ?
// to test to test if IRvalue <3 still persists over time
if (IRvalue < 3) { //sensor output went low TRIGGERED
delay (6000); // wait a while
if (IRvalue < 3) { //sensor output still low
myservo.writeMicroseconds(1200); // tell servo to go to active position
delay(1200); // wait for the servo to reach the position
myservo.writeMicroseconds(600); // tell servo to return to passive position
count=count+1; //tally time validated event
}
} // ... loop again