Creative Commons License

arduino oil dispenser

we all love food isn’t that right? of course yes, everyone has tried cooking once in their life, and already knows the struggle to get exact amount of oil for the perfect recipe, so here is a project which will help you get it correct, follow the instructions till the end and you will have a beautiful Arduino Based OIL DISPENSER


Step 1: so Watch the Video ( arduino oil dispenser)



Step 2: Designing for arduino oil dispenser


to get the wheels running, you first need a wheel right? ” so, to make some project, design is the most important aspect.

 so i first created a simple paper sketch to get an idea about what my end product should look like!

also after which, i measure the dimensions of components and considered other parameters like amount of space it requires, size of container etc.

i kept the screen and UI Buttons at an Angle so that its easy to control and little more user friendly.

so i have attached picture which contain the dimension of the design i used for each part, just in case if you want to create the exact one


Step 3: Gather the Requirements for arduino oil dispenser


We will Need the Following Items to Build our Awesome ARDUINO Based OIL Dispenser


  1. I2C L.C.D. Display:…
  2. Arduino UNO:….
  3. N Channel Mosfet:…
  4. Push Button Switch:…
  5. Prototyping Board:…
  6. Pump:…
  7. Resistors :(330,620,1k,2k,3.3k)…
  8. 6mm Pipe:…


Step 4: Gather Tools


we will also require some tools for this build


  1. Solder Iron:…
  2. Screw Driver:…
  3. Cutter:…
  4. Scissors:…
  5. Solder Wire:…


Step 5: Build the Circuits


arduino oil dispenser
for the Circuit, i used ARDUINO UNO as the brains of the entire project, I2C L.C.D. for Display,Push Buttons to interact with the user, DC Peristaltic pump to control the flow of oil, N Channel Mosfet as a Switch to Control Motor.

for ease of connections and Understanding, we will divide the electronics into 3 Blocks

1. Control Unit

2. MOSFET Module

3. Keypad Module

4. I2C L.C.D.



input (DATA) from the Keypad Module to Pin A0,

Vcc to D8


Mosfet Control


Ground to Ground

Output for Display

SCL/A5 to SCL and SDA/A4 to SDA of LCD and VCC to VCCGround to Ground


Motor From Mosfet Module Through M+ and M- Pins,

External Power to Mosfet Module at VCC and GND

if you are not good at Using Prototype board, you can use the Provided Gerber File to Order PCB Online and then Follow the above Connections



Step 6: Upload the Code

arduino oil dispenser

by "Akshay Momaya"
for "Mission Critical" ( youtube )
******subscribe for more ARDUINO projects and tutorials******

#include Wire.h
#include LiquidCrystal_I2C

LiquidCrystal_I2C lcd(0x27, 16, 2);

int keypad_pin = A0;
int Keypad_value = 0;
int Keypad_value_old = 0;
char Btn_push;
int Pump1 = 2;
int volume = 10;
int volumeOld = 10;
int Pump1State =0;
int MenuPage =1;
int MenuPageOld =1;
long previousMillis = 0;  
unsigned long currentMillis ;
long interval = 1000;
unsigned long multiplier = 450; 

//value to change based on calibration
//multiplier = milliseconds needed to fill 1ml liquid

void setup()
  lcd.init(); //Initialize a 2x16 type LCD
  pinMode(Pump1, OUTPUT);  
  pinMode(10, OUTPUT);  
        lcd.print("Mission Critical");
        lcd.print("Oil Dispenser");


void loop()
    Btn_push = ReadKeypad();
    //Change menu

    if(Btn_push == 'L') MenuPage =1;
    if(Btn_push == 'R') MenuPage =2;
    if(MenuPage != MenuPageOld)
        MenuPageOld = MenuPage;

    if(MenuPage ==1)
        if(Btn_push == 'U' && volume <100)

       if(Btn_push == 'D'&& volume>0)
        if(volumeOld != volume)  //update lcd when got new volume
            lcd.print("ml ");
            volumeOld = volume;
        if(Btn_push == 'S' )
    if(MenuPage ==2)
       if(Btn_push == 'S')
           if(!Pump1State )
             lcd.print("freeflow run ");
             Pump1State =1;
             lcd.print("freeflow stop");
             Pump1State =0;


//------------- – End of loop() loop – -------------------

void MenuDisplay(int page)
    switch (page)
       case 1:
          lcd.print("Volume: ");
          lcd.print("ml ");
       case 2:
          lcd.print("MANUAL MODE");

void RunPump(unsigned long ml)

    previousMillis = millis();
    currentMillis = previousMillis;
    interval = ml * multiplier;
        lcd.print("ml ");
    while(currentMillis - previousMillis < interval)
        currentMillis = millis();
        lcd.setCursor(0, 1);
        lcd.print((currentMillis - previousMillis)/1000);
        lcd.setCursor(0, 1);
        lcd.print((currentMillis - previousMillis)/1000);

char ReadKeypad()
  /* Keypad button analog Value
  no button pressed 1023
  select  741
  left    503
  down    326
  up      142
  right   0 
  Keypad_value = analogRead(keypad_pin);
  if(Keypad_value < 100)
    return 'R';
  else if(Keypad_value < 200)
    return 'U';
  else if(Keypad_value < 400)
    return 'D';
  else if(Keypad_value < 600)
    return 'L';
  else if(Keypad_value < 800)
    return 'S';
    return 0;



Step 7: Prepare the Tank ( Reservoir)


to Prepare the tank,

first keep the container and motor on a flat surface, and mark the motor inlet for fluid and continue by creating a hole in the container, after which, insert the liner and use Hot Glue to Seal the Liner and ensure that there are no leaks, by running some water through the Reservoir.


Step 8: Prepare the Enclosure for arduino oil dispenser


I used mount board, which is not the best choice, yet economic and readily available. so to make this enclosure,


  1. Mark the Dimensions from Step 2 using a pencil.
  2. Cut the Right, Left, Top, Back, Bottom, Front Panel, Front Side pieces using Scissor or Box Cutter.
  3. Use HOT Glue gun to seal all the side.
  4. Use small right angled triangle cut out of any size to provide extra support.
  5. Mount the L.C.D on Front Panel using M3 nuts and bolts.
  6. Use Hot Glue to secure Keypad Module in the Designated Holes.
  7. Give the Box a Final Touch up with Hot Glue to fill up remaining holes.


Step 9: (optional) Add Lightings


to light up the interior of the box, i used a 12V strip LED.

to install it, simply apply a drop of Hot Glue and Work the Length through the interior of BOX just above the dispenser Pipe Outlet


Step 10: Calibration (MOST IMPORTANT)


calibrating the system,is basically measuring the time required to fill 1milliliterof liquid in X milliseconds.

For which I used a Beaker which had a little less resolution, so I calculated the time required to fill 100 ml of liquid and thus calculated the rate of flow, which turned out to be 450 microseconds in my case.

arduino oil dispenser


  1. Reset The Stop Watch.
  2. Clear the beaker and set it under the Dispenser Outlet.
  3. Go to Manual Mode page of U.I.
  4. Press Start to Begin the test.
  5. Observe the Volume, STOP the Watch when volume is 100 ml Exact and Note Down The reading.
  6. so Divide the Seconds Reading by 100 ( cause we need to know time for 1 ml)
  7. so Multiply by 1000, you will get your Multiplying factor
  8. Change the Multiplying Factor in Line 32.
  9. also test and repeat if any error.


Step 11: Conclusion ( Possible Modifications)


we understood and built this project to successfully obtain oil in precise amounts, also we calibrated the system according to our specific application.

so this same project can be used to dispense water, juice or any fluid ( just remember to calibrate it, as every fluid has different volume).

also a few motor motors could be added to make a Cocktail Machine.

Write A Comment


A Market Place for your Innovations