const int pumpAPin = 9;  // Pin for Pump A
const int pumpBPin = 10; // Pin for Pump B

// Variables for the current amounts of Liquid A and Liquid B
float liquidA = 1.0; // ml, starting from 0
float liquidB = 1.0;  // ml, starting from 0

// Target ratio (5:2)
float targetRatio = 5.0 / 2.0;

// Variable to keep track of the total volume delivered
float totalVolume = 0.0;

void setup() {
  pinMode(pumpAPin, OUTPUT);
  pinMode(pumpBPin, OUTPUT);
  // Initialize pumps and other setup as needed
  Serial.begin(9600);
}

void loop() {
  // Calculate the current ratio
  float currentRatio = liquidA / liquidB;

  Serial.print("Current Amount - Liquid A: ");
  Serial.print(liquidA, 2); // Displaying with 2 decimal places
  Serial.print(" ml\t");
  Serial.print("Liquid B: ");
  Serial.print(liquidB, 2); // Displaying with 2 decimal places
  Serial.println(" ml");
  Serial.print("Current ratio: ");
  Serial.println(currentRatio, 2);

  if (currentRatio > targetRatio) {
    // Dispense more Liquid B
    digitalWrite(pumpBPin, HIGH);
    digitalWrite(pumpAPin, LOW);
    delay(1000);  // Adjust this delay for your system
    digitalWrite(pumpBPin, LOW);
    liquidB += 4.0;
  } else {
    // Dispense more Liquid A or stop both pumps if the ratio is as desired
    digitalWrite(pumpAPin, HIGH);
    digitalWrite(pumpBPin, LOW);
   delay(1000);  // Adjust this delay for your system
    digitalWrite(pumpAPin, LOW);
    liquidA += 3.0;
  }

  // Update the total volume delivered
  totalVolume = liquidA + liquidB;

  Serial.print("Total Volume Delivered: ");
  Serial.print(totalVolume, 2); // Displaying with 2 decimal places
  Serial.println(" ml");
  delay(500);
}