need help with code for controlling a hydraulic press mode

Also you need to have some de-bounce on the counter pin if it is a mechanical switch or you will count the contact bounces as well giving false readings.