Make your own coffee vending machine Control circuit

Published by MKDas on

In this article, we are going to make our own control card for coffee vending machines. This machine is nowadays very common in shops and restaurants. Small businesses can be started with this machine. Here let’s make a simple functional control card for the vending machine.

Disclaimer: Electricity is always dangerous. Skill required to work with electricity. Do work with your own risk. Author will not be responsible for any misuse or harmful act. This website contents is also copyright protected. Anything copied and directly posted in your website and claiming it as yours is prohibited and nonsensical. Author published all the articles as opensource to help you making your project and learning purpose only. Learn and make one for yourself. If need any help feel free to ask the author. Author will be helpful to you. Thanks.

About coffee vending machine:

A coffee vending machine usually dispenses hot coffee. But getting tea and hot water is optional. Most of the vending machines have other features like milk, coffee-mate, etc. More elaborately sugar, flavor, etc. also can be added.

A common coffee vending machine

Some of these vending machines may have a keypad for password or RFID card scanning option. But in a very simple one, only a few basic options are kept.

These are:

  • Adding Coffee powder
  • Adding Tea powder
  • Adding Water
  • Adding Sugar
  • Mixing

Sometimes, sugar is premixed with tea/coffee. In this case, the mixture is called a premix. Here in South Asia, most of the coffee vending machines use the premixed powder for coffee & tea separately.

In this article, we are going to make the last type which uses premixed powders. In this case, we have only few devices to control. We can say these devices like this:


  • Premix1
  • Water1
  • Mixure1
  • Premix2
  • Water2
  • Mixure2

Here Mixure1&2 are motors to drive and rest of the devices are valves. We can use simple relays to drive these loads.

Here, Premix1, Water1, Mixure1 these are making coffee, and Premix2, Water2, and Mixure2 are making tea. Besides, to get hot water only, Water1 & Water2 work simultaneously.

Now, we can draw our circuit diagram.

Circuit Diagram:

Simulative circuit diagram

Here, Relays are presented by LEDs to simplify the circuit diagram so that you can understand it clearly. I’ve designed this circuit in PCB. You can watch this video to understand as well as practice to make one for yourself.

The video language is Bengali. If you do not understand kindly read the subtitles.

Programming & Simulation:

In this project I used mikroC pro for PIC as the compiler and proteus 8.9 as the simulator.

Program for, Coffee Vending Machine
Program Written by_ Engr. Mithun K. Das
MCU:PIC16F877A; X-tal:20MHz; Compiler: mikroC pro for PIC v7.6.0
Date: 24-12-2020

// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB4_bit;
sbit LCD_D4 at RB3_bit;
sbit LCD_D5 at RB2_bit;
sbit LCD_D6 at RB1_bit;
sbit LCD_D7 at RB0_bit;

sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB3_bit;
sbit LCD_D5_Direction at TRISB2_bit;
sbit LCD_D6_Direction at TRISB1_bit;
sbit LCD_D7_Direction at TRISB0_bit;
// End LCD module connections

void Lcd_COut(char row, char col, const char *cptr)
  char chr = 0;             //first, it is used as empty string
  Lcd_Out(row, col, &chr);  //nothing to write but set position.
  for ( ; chr = *cptr ; ++cptr ) Lcd_Chr_CP(chr); //out in loop

//define buttons here
#define    TEA          RA0_bit
#define    COFFEE       RA1_bit
#define    HALF         RA2_bit
#define    HOT_WATER    RA3_bit

//define outputs here
#define    Buzzer       RD3_bit
#define    Relay1       RC4_bit
#define    Relay2       RD2_bit
#define    Relay3       RC5_bit
#define    Relay4       RC6_bit
#define    Relay5       RC7_bit
#define    Relay6       RD4_bit

int rl1_counter;// 50 = 5 sec    //premix1
int rl2_counter;                 //water1
int rl3_counter;                 //wiper1
bit tea_activation;

int rl4_counter;// 50 = 5 sec    //premix2
int rl5_counter;                 //water2
int rl6_counter;                 //wiper2

bit coffee_activation;
bit hot_water_activation;
bit edit_mode;
int division=1;

int edit_mode_entry_counter=0;
short edit_page=0;

#include "subfunctions.h"

I’ve described the complete code with simulation side by side. Please watch these videos to understand the code.

Part # 1:

Part # 2:

Part # 3:


Testing the circuit:

Here is the test result with our designed circuit.


In the end, we can say that if anyone read this article with concentration, watch the videos carefully it is not a difficult job to make his/her own control card.

I hope this project was helpful to you. If you make one for yourself, it will be a great pleasure for me. Anywhere you need help, let me know. Please share this project and subscribe to my blog. Thank you.


Mithun K. Das; B.Sc. in EEE from KUET. Blog:


Joy · February 24, 2021 at 5:12 pm

Nice….Go ahead.. Thank you.

Ajape · March 3, 2021 at 11:12 am

Good day engr Mithun. Thanks for this new development. How I wish I could understand Indian language, as I am from Nigeria, but I don’t really grab your explanation, and the code in the video is not clearly seen and I really want to learning it and do it. I have practice many of your projects on your blogs, based PIC controller. Please. If you could send me the source code and the schematic diagram of this COFFEE VENDING MACHINE CONTROL CIRCUIT. my Gmail address is:
Secondly sir. There is one project you had posted in your previous blogs: DIGITAL MULTIMETER” I have been searching for it but I couldn’t find it again. Please I need your help if you could send them to me, I would be very grateful sir. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *