I used an ESP8266 but you can use a member of the arduinom family as well as you will not need wifi.
Even an Attiny85 would do. But for rapid prototyping I used an ESP8266 (and they are dead-cheap to !!).
An HC-SR04 is attached to the ESP8266 as well as a small pump (controlled by a tip120 power transistor) and 2 leds. When your hand nears the HC-SR04 the pump starts pumping soap for a few seconds. Then a red led goes ON for 20 seconds so you know how long to wash your hands.
This way you have a safe and sterile means to wash your hands. You do not need a handpump and you do not need to touch anything. Please share to those who might be interested.
Schematics and source code (in Arduino IDE) on my weblog:
http://lucstechblog.blogspot.com/2020/0 ... g-aid.html
Stay inside and safe !!
Luc