How to modify loadcell

Hello!, Good afteernoon,
I have made weight machine for measuring the weights.
I want to know that how can i modify my code such that when i put a value in grams the machine should fill that much amount of material in a bag.
For example:- if i put a value such as 50 grams with the help of the keypad and then the servo opens the lid of the dispensor and when the loadcell gets value of 50 grams it will give message to servos that stop the bag is 50 grams full.

The code which i have to modify is below:-

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#define DT A0
#define SCK A1
#define sw 9

long sample=0;
float val=0;
long count=0;

unsigned long readCount(void)
{
unsigned long Count;
unsigned char i;
pinMode(DT, OUTPUT);
digitalWrite(DT,HIGH);
digitalWrite(SCK,LOW);
Count=0;
pinMode(DT, INPUT);
while(digitalRead(DT));
for (i=0;i<24;i++)
{
digitalWrite(SCK,HIGH);
Count=Count<<1;
digitalWrite(SCK,LOW);
if(digitalRead(DT))
Count++;
}
digitalWrite(SCK,HIGH);
Count=Count^0x800000;
digitalWrite(SCK,LOW);
return(Count);
}

void setup()
{
pinMode(SCK, OUTPUT);
pinMode(sw, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print(" Weight ");
lcd.setCursor(0,1);
lcd.print(" Measurement ");
delay(1000);
lcd.clear();
calibrate();
}

void loop()
{
count= readCount();
int w=(((count-sample)/val)-2*((count-sample)/val));
lcd.setCursor(0,0);
lcd.print("Measured Weight");
lcd.setCursor(0,1);
lcd.print(w);
lcd.print("g ");

if(digitalRead(sw)==0)
{
val=0;
sample=0;
w=0;
count=0;
calibrate();
}
}

void calibrate()
{
lcd.clear();
lcd.print("Calibrating...");
lcd.setCursor(0,1);
lcd.print("Please Wait...");
for(int i=0;i<100;i++)
{
count=readCount();
sample+=count;
}
sample/=100;
lcd.clear();
lcd.print("Put 100g & wait");
count=0;
while(count<1000)
{
count=readCount();
count=sample-count;
}
lcd.clear();
lcd.print("Please Wait....");
delay(2000);
for(int i=0;i<100;i++)
{
count=readCount();
val+=sample-count;
}
val=val/100.0;
val=val/100.0; // put here your calibrating weight
lcd.clear();
}

Note:- 1) The value can be changeable.
2)The code and circuit diagram should be provided.
3) Most Important- NO pcbs and 3d printer should be used.

Components I have:-
Arduino uno
16*2 lcd
breadboard jumperwires
Trim variable resistor
20kg loadcell
hx711
keypad
servo motors x2
And any other things needed so please tell me.

**Budget:- **$25 bucks.

Help:- Please Modify the code.

please somebody help me to complete this project…

This belongs in the Gigs and Collaborations section

Do you want it moved there ?

yes

Moved to Gigs and Collaborations at the request of @divyanshsingh

What weight of material will be “in flight” at the time the bag weighs 5 grams and the gate is closed?
Paul