Make ISR function from polling function

I dont think that switch statement would be the best in my case, because i need 1 initial long pulse, and after that somwhere between 10 to 20 pwm pulses, and it will change, how long i need to make solonoid stay open based on other variables. Need to think of some other logic :smiley: