Need Help Figuring out why this won't upload

I'm a senior at federal high school in Brazil, and I need to finish this project to graduate.
Anyways, it include a TCS3200 RGB sensor, LDR sensor, relay and a robotic arm equipped with 4 servos. I've been working on it for a while now, but when I upload a code with al the components included in its working, it does upload. I get this:
Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"

Sketch uses 5108 bytes (15%) of program storage space. Maximum is 32256 bytes.

Global variables use 257 bytes (12%) of dynamic memory, leaving 1791 bytes for local variables. Maximum is 2048 bytes.

An error occurred while uploading the sketch

So, I need help figuring this out, any help will be appreciated.

this is the code:

#include<SoftwareSerial.h> // library for setting bluetooth input and output pins

VarSpeedServo claw;  // Declaração de do servo motor que controlam o movimento do braço
int claw_pin = 2;    // Declaração do pino do servo
VarSpeedServo base;  
int base_pin = 3;
VarSpeedServo left;
int left_pin = 4;
VarSpeedServo right;
int right_pin = 5;

#define S0 A0   // Definição dos pinos do sensor RGB 
#define S1 A1
#define S2 A2
#define S3 A3
#define out A4

int ldr = A5;        // Declaração do pino do Sensor LDR
int light_level = 0; // Variável representante do nível de luz
int ldr_key = 0;     // Variável chave 

int color;// switch case control key based on RGB results

const int relay = 6; // Declaração do relé

char data; // Variável bluetooth
SoftwareSerial Bluetooth(0, 1); // Declaração dos pinos de RX & TX

void setup(){
  Bluetooth.begin(9600);
  
  base.attach(base_pin, 1, 180); // Connectando o servo ao seu devido pino
  claw.attach(claw_pin, 1, 180);
  left.attach(left_pin, 1, 180);
  right.attach(right_pin, 1, 180);

  base.slowmove(90, 40); // Posições inciais
  claw.write(30);
  left.slowmove(100, 40);
  right.slowmove(170,40);

  pinMode(A0, OUTPUT); // Incializando os estados dos pinos do sensor TCS 3200
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(A4, INPUT);
  
  pinMode(ldr, INPUT); // Inicializando o sensor LDR
  
  pinMode(relay, OUTPUT);   // Incializando o relé
  digitalWrite(relay, LOW); // Ligando os LEDs
}

void loop(){
  lights(); // Controle dos luzes LED via Bluetooth
  ldr_key = ldr_sub(); // Detecção de objetos por meio de um sensor LDR
  if(ldr_key == 1){ // Incialização da condição, caso tem objeto presente
    left.slowmove(60, 40); // Extensão do braço
    delay(500);
    color = color_sub(); // Leitura do cor
    delay(500);
    claw.write(20);
    delay(500);
    left.slowmove(100, 40);
    delay(500);
    switch(color){ // casos de movimento conforme o cor do objeto
      case 1: // Azul
      base.slowmove(0, 40);
      main_movimento();
      break;
      
      case 2: // Verde
      base.slowmove(45, 40);
      main_movimento();
      break;
      
      case 3: // Vermelho
      base.slowmove(135, 40);
      main_movimento();
      break;
      
      case 4: // Branco
      base.slowmove(180, 40);
      main_movimento();
      break;
    }
  }
}

int ldr_sub(){ // Sub rotina responsável pelo controle dos Luzes LEDs
  light_level = analogRead(ldr);
  if(light_level < 900){
    delay(2000);
    if(light_level < 900){
      return 1;
    }
    else{
      return 0;
    }
  }
  else{
    return 0;
  }
}

void lights(){ // LED lights controller subroutine
  if(Bluetooth.available()){
    data = Bluetooth.read();
    if (data == '1'){
        digitalWrite(relay, HIGH); // LEDs On
      }
      if (data == '2'){
        digitalWrite(relay, LOW); // LEDs Off
      }
   }
}

void main_movimento(){  // Sub rotina de movimento padronizado de extenção e retração do braço
  left.slowmove(60, 40);
  claw.write(30);
  delay(1000);
  left.slowmove(100,40);
  delay(500);
  base.slowmove(90,40);
}

int color_sub(){ // Subrotina responsável pela leituras de cores
  int red = 0;   
  int green = 0;
  int blue = 0;
  int color;
  analogWrite(S0,HIGH); // Bloco de comando que alterar o estado dos pinos
  analogWrite(S1,LOW);  // da escala de frequencia de saída e dos Fotodiodos,
  analogWrite(S2,LOW);  // assim permintindo a leitura dos cores por meio de 
  analogWrite(S3,LOW);  // laço de condições adiante
  red = pulseIn(out, LOW);
  analogWrite(S2,HIGH);
  analogWrite(S3,HIGH);
  green = pulseIn(out, LOW);
  analogWrite(S2,LOW);
  analogWrite(S3,HIGH);
  blue = pulseIn(out, LOW);

  if( red == 1){return 4;}// Verifica se vermelho foi detectada OBS. Falta inserir o condição de detecção do branco
  else{
    if (red < blue && red < green && red < 100) // Verifica se vermelho foi detectada
      {return 3;}  
    else{
      if (blue < red && blue < green && blue < 1000) // Verifica se azul foi detectada
        {return 1;}
      else{
        if (green < red && green < blue) // Verifica se verde foi detectada
          {return 2;}
        }
      }
    }
}

this is the fritzing schematic for the circuit (ignore the LCD display, its been discarded as an idea) :

You forgot to include the VarSpeedServo library.

There are several warnings that will not prevent the program from loading, but should be addressed.

In the future please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Are you really powering the servos and relay from the Uno 5V or USB?

Your post was MOVED to its current location as it is more suitable.

If you have a Bluetooth interface connected to Pin 0 and Pin 1 it is probably interfering with the upload. Disconnect it when trying to upload.

If you are going to use the hardware serial pins Pin 0 and Pin 1 for serial, use the built-in 'Serial' object and not the SoftwareSerial library.

#define Bluetooth Serial

void setup(){
  Bluetooth.begin(9600);

Actually, I just missed it when I copied and pasted it. But thanks for the help

That is the all entire error message, I did as you indicated in the post. And I am powering everything from the UNO 5V, which is power via USB from my laptop.

I actually do know to disconnect RX & TX when uploading the programs, I lost several weeks of work due to not knowing this fact before hand. And I'll try using #define Bluetooth Serial instead of #include<SoftwareSerial.h>.
Thanks for the tip, hope it works. :sweat:

The servos (at least) need an external power supply. The supply must be able to supply the current required by the servos. Neither the USB nor the Uno 5V regulator can supply sufficient current. See this Pololu page for a discussion on powering servos..

And I would suggest that you use an I2C enabled LCD. That will free up 4 pins (I2C only needs 2, A4 and A5) so that you can put the HC05 on a software serial port on different pins than 0 and 1. Then you can use the hardware serial port (USB) for program upload, debug and output.

that actually explains a lot, because I had noticed that the servos where having a hard time moving when I used other programs with the same circuit. The program would up load, but the servos wouldn't move and didn't seem to lock in place like they typically do. Thanks, very helpful.

Hi guys, turned out the 0 & 1 pins on the uno mess with the communication, when we changed them to different pins it uploaded perfectly. Just dealing with a problem powering all the components, but thanks for the help.

how do I close this thread?

It will autoclose after some (four?) months. You can click on solution in your final (or indeed any) post to give a visual indication that you don't need any more help.