So, I want to make a hand sanitizer. I have an ultra-sonic sensor.
Right now it works like this: when distance is lower than 5cm, it pours liquid.
What I want to do is: when distance < 5 cm, pour for 2 seconds. After the 2 second have passed, wait another 3 seconds before measuring again.
Ex: I put my hand in front on sensor, it pours liquid for 2 seconds. After that it waits for 3 seconds then it's ready to pour again if distance < 5 cm.
Thank you, it would be of much help. I really don't know how to implement a timer like this.