Whenever the proximity sensor is ON strokeCount is increased by 1. When the strokeCount is 10, a relay is activated thru an NPN transistor for a period specified by the variable Duration and then the variable strokeCount is intialized.
However, physically the code is not performing as expected. The relay is being activated on every pulse received from the sensor. I have tried various changes but nothing improved. It seems that the value of digitalRead(sensorInput) is always HIGH which makes the 2nd IF condition always TRUE. But, the voltage at pin 6 is always LOW when sensor is OFF.
I'm no expert but I think that opto-isolator has an Open Collector output and it is wired incorrectly. You would put the pull-up resistor between the upper terminal (Collector?) and +5V. Connect the upper terminal also to the ATtiny input pin. Connect the lower terminal (Emitter?) directly to Ground.
If that really is an open-collector sensor (NPN), then the opto-isolator is serving no purpose. Connect the output lead directly to the tiny85 and pull the input pin high with that 4.7k resistor, or use the INPUT_PULLUP configuration.
Next thing is to be sure that nothing is triggering the sensor and see if you get the same behavior. Normally I'd say print something out the serial port, or flash the built-in LED when the sensor is triggered, but this isn't a regular Arduino!