---
title: "avr_flow: a new brain for a liquid vending machine"
description: "An ATmega328 controller that replaced the limited PLC of a coin-operated liquid dispenser, with a flow meter, a pump and a 4-digit display."
date: 2015-03-01T14:47:53+01:00
lastmod: 2026-10-16T18:58:52+02:00
url: https://klimek.link/projects/avr-flow/
author: "Marcin Klimek"
source: https://klimek.link/projects/avr-flow/
---

# avr_flow: a new brain for a liquid vending machine

This machine sold liquid for coins, but the PLC-based controller it came with could do very little. I took it out, put a small **ATmega328** board in its place (an Arduino Pro Mini running at 8 MHz) and wrote new firmware for it, **avr_flow**.

## What the firmware does

Three coin acceptors add credit, and a running total of coins is saved to EEPROM, so the count survives power cuts. Pressing start switches on the pump. A flow meter sends pulses as liquid goes through, the firmware counts them and turns the pump off once customers get what they paid for, unless somebody presses stop earlier.

*Diagram: What the ATmega328 reads and what it drives*

While pouring, a 4-digit LED display counts down how much is left to dispense, and a status LED blinks faster and faster as the paid amount runs out. Owners set the price of a token with the buttons, and that value goes to EEPROM as well. There's also an inactivity timeout and a buzzer.

Before building anything I simulated the display circuit in Proteus; those simulation projects and a photo of the hardware are in the repository too.

A few years later the same kind of machine got a Raspberry Pi successor, the [liquid dispenser with a touchscreen](/projects/vending-dispenser/).

[Source on GitHub](https://github.com/marcinklimek/avr_flow).

Source: https://klimek.link/projects/avr-flow/
