Combining Sketches and work step by step

Good Day!
I'm new on arduino uno programing and We have a project called Mini Smart Garbage Disposer and I
know how to program the Servo Motor, 3kg Weight Sensor with the LCD and the line tracing robot one by one but I dont know of how to combine them in one program.

With our struggles of watching and learning of tutorials to combine them, the result will get error.
We only have 4 days to present our project and we are seeking help of coding the 3 sketches in step by step.

1st The line tracing will pause on the position from (position A = Home)
2nd If the 3kg weight sensor is full, the line tracing will move to (position B = Dumping site)
3rd Once it stop in the Position B, the servo motor runs
4th Having 3 servo motor, one servo motor will run in a desired position and pause this serve as opening of the door, after that 2 servo motor will run in a desired position and pause for 15 seconds this is inside from the garbage disposer to dispose, after that from inside and the door will close.
5th from a Position B, if the weight sensor senses 0.8kg below, the line tracing will return to the Position A. if it senses 0.9kg above the servo motor will run repeatedly.

That's all we need or we can send our code to check or change what we go wrong.

Thank you.

The usual approach is to post your code inline with tags so the forum members can see it. (( There’s a guide at the top of each forum section.))

Depending on your first effort, you may not like some of the comments because we can be rather terse, especially with 48 hours to go !

Also, I wrote a very simple guide to help when merging code, but merging sketches is not really a good place to start. Take a look in the Introductory Tutorials section, there are a lot of guides to point newbies in the right direction.

My approach would be:
Write basic demo code ASAP for each part - lcd, weight sensor, and servo - make sure you can control each one on it's own, and that the hardware isn't broken. These el-cheapo parts from china have non-zero DOA rates (i mean, a servo costs less than a cup of coffee, you can't expect them to test the parts and such for the prices you pay) - I always buy at least 3 of anything that isn't prohibitively expensive, on the grounds that i'll lose one and burn out the second (if it's not DOA)
Start with the test code for the LCD. Add in minimal code to read the weight sensor (probably to serial?) and drive the servo (to catch library conflicts and the like). Then proceed to write the UI code and then add the functionality to interact with servo and weight sensor.

Thank you for replying my question and sorry for the delay, we had to do a construction on our robot and make a few changes, the structure of our robot that from inside of the trashcan/garbage instead of using the 2 servo motor to tilt, we change it to a already tilt structure from inside. it is a good thing to make because of lessen the programming code for the servo and we all need to just one servo motor that is the door, and don’t worry we just borrowed the two servo from our friend. Upon that may have accidentally damage or broken the LCD alongside the I2C module and since we only have two more days to present we enter the alternative code from the weight sensor that is without the LCD.

Thank very much for the support and giving me some tips of coding.

Here’s the new code that I work, it may have many errors and have some missing code

#include “HX711.h”
HX711 scale(A2 ,A3);
// DOUT - pin #A2
// SCK - pin #A3

#include <Servo.h>

int vSpeed = 110;
int turn_speed = 230;
int turn_delay = 10;

//L293 Connection
const int motorA1 = 8;
const int motorA2 = 10;
const int motorAspeed = 9;
const int motorB1 = 12;
const int motorB2 = 13;
const int motorBspeed = 11;

//Sensor Connection
const int left_sensor_pin = A0;
const int right_sensor_pin = A1;

int left _sensor_state;
int right_sensor_state;

// Servo connections
Servo myservo;

int servo_position = 0;

// Weight sensor
const int weight = 100g;

void setup() {

//Servo Void setup
myservo.attach (6);

//Motor Void setup
pinMode(motorA1, OUTPUT);
pinMode(motorA2, OUTPUT);
pinMode(motorB1, OUTPUT);
pinMode(motorB2, OUTPUT);

Serial.begin(9600);

delay(3000); // 3s delay
}

void loop() {
Serial.print(scale.getGram(), 1);
Serial.print(" g");
delay(200);
}
if ( weight >= 3000g)

// The line tracing will to Position B

left_sensor_state = analogRead(left_sensor_pin);
right_sensor_state = analogRead(right_sensor_pin);

if(right_sensor_state > 500 && left_sensor_state < 500)
{
Serial.println(“turning right”);

digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,LOW);
digitalWrite(motorB2,HIGH);

analogWrite (motorAspeed, vSpeed);
analogWrite (motorBspeed, turn_speed);

}
if(right_sensor_state < 500 && left_sensor_state > 500)
{
Serial.println(“turning left”);

digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);

analogWrite (motorAspeed, turn_speed);
analogWrite (motorBspeed, vSpeed);

delay(turn_delay);

}
if(right_sensor_state > 500 && left_sensor_state > 500)
{
Serial.println(“going forward”);

digitalWrite (motorA2,LOW);
digitalWrite(motorA1,HIGH);
digitalWrite (motorB2,HIGH);
digitalWrite(motorB1,LOW);

analogWrite (motorAspeed, vSpeed);
analogWrite (motorBspeed, vSpeed);

delay(turn_delay);

}

if(right_sensor_state < 500 && left_sensor_state < 500)
{
Serial.println(“stop”);

analogWrite (motorAspeed, 0);
analogWrite (motorBspeed, 0);

}
if (motorAspeed = 0 & motorBspeed = 0) digitalWrite( 9, HIGH);
}
for (servo_outside = 50; servo_outside <=110; servo_outside +=1){

// The servo motor/door opens

for (servo_position = 50; servo_position <=110; servo_position +=1){

myservo.write(servo_position);
delay(1000);
delay(300);
}

// The servo motor/door closes

for (servo_position = 110; servo_position >=50; servo_position -=1){

myservo.write(servo_position);
delay(2000);
}
// The weight sensor senses the weight
{
if (weight <= 100g);
// the line tracing will return to the Position A

else (weight >=100g);
// its still 100g above the servo motor go on repeat

}
{
Serial.println(“start”)
}
if(right_sensor_state < 500 && left_sensor_state > 500)
{
Serial.println(“turning left”);

digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);

analogWrite (motorAspeed, turn_speed);
analogWrite (motorBspeed, vSpeed);

delay(turn_delay);

}
if(right_sensor_state > 500 && left_sensor_state > 500)
{
Serial.println(“going forward”);

digitalWrite (motorA2,LOW);
digitalWrite(motorA1,HIGH);
digitalWrite (motorB2,HIGH);
digitalWrite(motorB1,LOW);

analogWrite (motorAspeed, vSpeed);
analogWrite (motorBspeed, vSpeed);

delay(turn_delay);

}
}

if(right_sensor_state < 500 && left_sensor_state < 500)
{
Serial.println(“stop”);

analogWrite (motorAspeed, 0);
analogWrite (motorBspeed, 0);

}

}

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

Your code is too long for me to study quickly without copying to my text editor. The text editor shows line numbers, identifies matching brackets and allows me to search for things like all instances of a particular variable or function.

Also please use the AutoFormat tool to indent your code consistently for easier reading.

...R

O.k. well that code doesn't even compile so it obviously doesn't do anything.

I'd suggest doing an AutoFormat (Ctrl-T) first and then sorting out your braces {} which seem to have been dropped in more or less at random. I'll give you the first one...you have a } which finishes loop() after the delay(200) so everything after that is not inside any function which definitely isn't allowed and will cause a load of errors.

Then you can fix some of the oddities like 'const int weight = 100g;' The characters 100g are not an integer. An int only takes numbers, you can't go adding odd characters on the end for good luck.

Steve