simple two position servo

tomswell:
Thanks for your interest ... component count / cost is part of design decision making. I posted under programming a question about nested If statements and I think I'll go with that approach:

// to test to test if IRvalue <3 still persists over time to avoid false triggering

if (IRvalue < 3) {                                         //sensor output went low  TRIGGERED
    delay (6000);                                         // wait a  while for validation that rattie is munching
                                                              // may include pot value for easy adjustment in final build
    if (IRvalue < 3) {                                    //sensor output still low
       myservo.writeMicroseconds(1200);         // tell servo to go to active position
       delay(1200);                                      // wait for the servo to flip over open cylinder in trough 180°
       myservo.writeMicroseconds(600);          // tell servo to return to passive position
       count=count+1;                                  //tally time validated event
       serial print (count);                            //  thru Max7219 & twin 8 segment leds     
}
    } // ... loop again



I'm toying with thoughts of storing (total_counts) where as (count) would be cleared with reset or battery change. I'm guessing that it would be not be worth having small aux battery to preserve memory ... or the inclusion additional no volatile ram ( if that’s even possible.)

Sorry, I may be missing something here, but without re-establishing IRvalue again (e.g.

IRvalue = analogRead (SENSOR)/100

What's the point in recomparing it to 3??