you hv to fix and set the limit. you can vary it as per ur requirements. but once desire limit is reached u hv to fix it.
if u want simple circuit u can easily get it on google. or if u want sensor and micro controller based circuit go for arduino platform