NEED HELP to Program a Batching System

Thank You So Much PaulS, :slight_smile: :slight_smile: :slight_smile:

Hope if i Stuck in future, you all are here to help me out.

Thank you All.

Here is my Code

#define RELAY_ON 0
#define RELAY_OFF 1
const int rly = 12;
const int rly2 =11;

#include "HX711.h"
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {21, 20, 19, 18}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {17, 16, 15, 14}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

#define calibration_factor -42990.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define zero_factor -51468 //This large value is obtained using the SparkFun_HX711_Calibration sketch


#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

boolean valOnePresent = false;
boolean next = false;
boolean final = false;
String num1;
int ans = 10000;
int ans2 = 10000;
char op;

void setup() {
  digitalWrite(rly, RELAY_OFF);
  digitalWrite(rly2, RELAY_OFF);
  lcd.begin(16,2);  


  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.set_offset(zero_factor); //Zero out the scale using a previously known zero_factor

  lcd.setCursor(0,0);
  lcd.print("Readings:");

  pinMode(rly, OUTPUT);
  pinMode(rly2, OUTPUT);

}

void loop() {
  lcd.setCursor(0,0);
  lcd.print("Target Wt: ");
  lcd.setCursor(0,1);
  lcd.print("Wt: ");
  lcd.setCursor(5,1);
  lcd.print(scale.get_units(), 1); //scale.get_units() returns a float
  lcd.print("0 kg      "); //You can change to kg but you'll need to change the calibration_factor

  char key = customKeypad.getKey();
  if (key != NO_KEY && (key >= '0' && key <= '9')){
    if (valOnePresent != true){
      num1 = num1 + key;
      int numLength = num1.length();
      lcd.setCursor(13 - numLength, 0); //to adjust one whitespace for operator
      lcd.print(num1);
      final = true;
      
    }
  }

  else if (valOnePresent == false && key != NO_KEY && (key == 'A' || key == 'B' || key == 'C' || key == 'D')){
    if (valOnePresent == false){
    valOnePresent = true;
    op = key;
    char opLength = sizeof(op);
    lcd.setCursor(13 - opLength, 0); //to adjust one whitespace for operator
    lcd.setCursor(13,0); //operator on right corner
    lcd.print("Kgs");
    }
  }

  else if (final == true && key != NO_KEY && key == '#'){
    if (op == 'A'){
      ans = num1.toInt();
      digitalWrite(rly, RELAY_ON);
      lcd.clear();
      lcd.print("Target Wt:");
      lcd.setCursor(12, 0);
      lcd.print(ans);
      lcd.print("KGs");
      lcd.noAutoscroll();
    }
    if (op == 'B'){
      ans2 = num1.toInt();
      digitalWrite(rly2, RELAY_ON);
      lcd.clear();
      lcd.print("Target Wt:");
      lcd.setCursor(12, 0);
      lcd.print(ans2);
      lcd.print("KGs");
      lcd.noAutoscroll();
    }
  }

  
  else if (key != NO_KEY && key == '*'){
    lcd.clear();
    valOnePresent = false;
    final = false;
    num1 = "";
    ans = 10000;
    op = ' ';
  }

     if (scale.get_units()> ans) {
   digitalWrite(rly, RELAY_OFF);
  }
     if (scale.get_units()> ans2) {
   digitalWrite(rly2, RELAY_OFF);
  }
}