Arduino Water Flow Meter with YF-S201 Sensor and LCD
Build a water meter: count a flow sensor’s pulses with an interrupt, show litres per minute and litres in total, and sound a buzzer when the bucket is full and the tap is still open.

Your project challenge
Count the pulses on D2 with an interrupt. Every second show Flow: and the litres per minute (pulses that second ÷ 7.5) on row 1, and Total: and the litres (all pulses ÷ 450) on row 2. From 5 litres show FULL: instead of Total:, and sound the buzzer while water still flows.
Components you’ll use
- Arduino Uno
- Water Flow Sensor (YF-S201)
- Piezo Buzzer
- LCD 16x2 Display
What you’ll build
A water meter for a tap. It shows how fast water flows and how much has passed, and it warns you when a 5-litre bucket is full. Water meters on homes measure your bill the same way.
How it works
Water spins a tiny wheel with a magnet inside the sensor. Each turn sends a pulse on the yellow wire: 7.5 pulses a second for every litre per minute, 450 for every litre. Use the tap slider to open the tap.
The key idea
Pulses come too fast to catch with digitalRead in loop(). attachInterrupt runs a tiny function on every pulse, even in the middle of loop(). Make its counter volatile, and copy it with interrupts off before you use it.
⚠ Watch out
Use 450.0, not 450, or the litres lose their decimals. Count the pulses in each second, not since the start, for the flow.
Make it yours: add a relay and a solenoid valve that closes the tap by itself at 5 litres.
The editor has the wiring guide, the code and the simulator.
Build this project