Modify program for drink dispencer

Hello everyone,
hoping that you could help me, I don’t know much about the Arduino language and I have a project to create a drink distributor. there is already a tutorial for this with a code on youtube but this one uses three pumps. Here is all my problem I would like to add a fourth pump.
Help me please !

tutorial link: https://www.instructables.com/id/Make-Your-Own-Crude-Cocktail-Machine/

CocktailMaker.ino (3.91 KB)

I don’t see how your question can have anything to do with the working of this website so I have suggested to the Moderator to move it to the Project Guidance section.

For short programs it is much easier for people to help if you include them in your Post using the code button </>

Have you got the program working properly with 3 pumps? If not I suggest you start with that.

…R

@flocorbab

Moved your topic to it's current location / section as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Adding a fourth pump looks fairly easy. Look at the places where ‘screen’ is used. Where the value of ‘screen’ is limited to 3, change that to 4. Where the value of ‘screen’ is used to select from among three different actions, add a fourth. Where there is “if (screen == 2 && doonce == 0)”, duplicate that section and make it for screen == 3. Then change the current “if (screen == 3 && doonce == 0)” to “if (screen == 4 && doonce == 0)”.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "HX711.h"
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
HX711 scale(5, 6);
#define clk 2
#define dt 3
#define sw 4
#define in1 7
#define in2 8
#define in3 9
#define in4 10
#define in5 11
#define in6 12
volatile boolean TurnDetected;
volatile boolean up;
bool doonce = 0;
char screen = 0;
boolean changestate = 0;
long weight;
int pump1ml = 20;
int pump2ml = 20;
int pump3ml = 20;




void isr0 ()
{
  TurnDetected = true;
  up = (digitalRead(clk) == digitalRead(dt));
}


void setup()
{
  lcd.begin(16, 2);
  pinMode(sw, INPUT_PULLUP);
  pinMode(clk, INPUT);
  pinMode(dt, INPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(in5, OUTPUT);
  pinMode(in6, OUTPUT);
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  digitalWrite(in5, LOW);
  digitalWrite(in6, LOW);
  attachInterrupt (0, isr0, RISING);
}


void loop()
{
  if (TurnDetected)
  {
    delay(200);
    doonce = 0;
    if (changestate == 0)
    {
      if (up)
      {
        screen++;
        if (screen > 3)
        {
          screen = 3;
        }
      }
      else
      {
        screen = screen - 1;
        if (screen < 0)
        {
          screen = 0;
        }
      }
    }
    else
    {
      if (up)
      {
        switch (screen)
        {
          case 0: pump1ml = pump1ml + 10;
            break;
          case 1: pump2ml = pump2ml + 10;
            break;
          case 2: pump3ml = pump3ml + 10;
            break;
        }
      }
      else
      {
        switch (screen)
        {
          case 0: pump1ml = pump1ml - 10;
            break;
          case 1: pump2ml = pump2ml - 10;
            break;
          case 2: pump3ml = pump3ml - 10;
            break;
        }
      }
    }
    TurnDetected = false;
  }




  if (digitalRead(sw) == LOW)
  {
    delay(200);
    changestate = !changestate;
    doonce = 0;
  }


  if (screen == 0 && doonce == 0)
  {
    lcd.clear();
    lcd.print("Vodka");
    lcd.setCursor(0, 1);
    lcd.print(pump1ml);
    lcd.setCursor(3, 1);
    lcd.print("ml");
    if (changestate == 0)
    {
      lcd.setCursor(9, 0 );
      lcd.print("Change?");
    }
    doonce = 1;
  }


  if (screen == 1 && doonce == 0)
  {
    lcd.clear();
    lcd.print("Cranberry");
    lcd.setCursor(0, 1);
    lcd.print(pump2ml);
    lcd.setCursor(3, 1);
    lcd.print("ml");
    if (changestate == 0)
    {
      lcd.setCursor(9, 0 );
      lcd.print("Change?");
    }
    doonce = 1;
  }


  if (screen == 2 && doonce == 0)
  {
    lcd.clear();
    lcd.print("Grpfruit");
    lcd.setCursor(0, 1);
    lcd.print(pump3ml);
    lcd.setCursor(3, 1);
    lcd.print("ml");
    if (changestate == 0)
    {
      lcd.setCursor(9, 0 );
      lcd.print("Change?");
    }
    doonce = 1;
  }


  if (screen == 3 && doonce == 0)
  {
    lcd.clear();
    if (changestate == 0)
    {
      lcd.print("Start?");
      doonce = 1;
    }
    else
    {
      lcd.print("Wait!");
      delay(2000);
      weight = scale.read();
      delay(100);
      lcd.clear();
      lcd.print("Pump 1 ON");
      digitalWrite(in1, HIGH);
      while (scale.read() - weight < 3000)
      {


      }
      
      lcd.clear();
      lcd.print(pump1ml);
      lcd.print("ml");
      delay((pump1ml / 11) * 1000);
      digitalWrite(in1, LOW);
      delay(2000);
      weight = scale.read();
      delay(100);
      lcd.clear();
      lcd.print("Pump 2 ON");
      digitalWrite(in3, HIGH);
      while (scale.read() - weight < 3000)
      {


      }
      lcd.clear();
      lcd.print(pump2ml);
      lcd.print("ml");
      delay((pump2ml / 12) * 1000);
      digitalWrite(in3, LOW);
      delay(2000);
      weight = scale.read();
      delay(100);
      lcd.clear();
      lcd.print("Pump 3 ON");
      digitalWrite(in5, HIGH);
      while (scale.read() - weight < 3000)
      {


      }
      lcd.clear();
      lcd.print(pump3ml);
      lcd.print("ml");
      delay((pump3ml / 12) * 1000);
      digitalWrite(in5, LOW);
      delay(2000);
      changestate = 0;
    }
  }
}