
An automatic water dispenser combines a distance sensor with a solenoid valve to pour water automatically without touching any switch, improving hygiene and reducing water waste compared to traditional taps.
Components needed
An Arduino Uno board, an HC-SR04 ultrasonic distance sensor, a solenoid valve to control water flow, an IRF540 MOSFET transistor to drive the valve, an indicator LED, and supporting resistors.
Wiring it up
The HC-SR04 sensor connects to the Trig and Echo pins as usual. The valve is never wired directly to an Arduino pin because it needs far more current than the pin can supply; instead, a digital pin drives the gate of the IRF540 transistor, which switches the current flowing to the valve on and off from a separate power supply matched to the valve's voltage and current requirements.
How it works
The code continuously measures distance through the sensor, and when any object (a cup or container) comes within 10 centimeters, the Arduino lights the indicator LED and sends an on signal to the IRF540's gate, opening the valve and letting water flow. Once the object is removed and the distance exceeds the set threshold, the valve closes automatically and water flow stops immediately, so the whole system runs with zero manual intervention.
You can find the HC-SR04 sensor, solenoid valves, and MOSFET transistors at Juthour Tech.
اترك تعليقا