Don't know what to do with this error... How to fix?

So i'm creating a firefighting robot and this is my code:

#include <Wire.h>
#include <Servo.h>

Servo myservo;

#define Left 8
#define Right 9
#define Forward 10
#define LM1 2
#define LM2 3
#define RM1 4
#define RM2 5
#define pump 6
#define smokeSensorPin A0
#define smokeThreshold 300

void setup() {
pinMode(Left, INPUT);
pinMode(Right, INPUT);
pinMode(Forward, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
pinMode(pump, OUTPUT);

myservo.attach(11);
myservo.write(90);
}

void sweepServo() {
for (int pos = 50; pos <= 130; pos += 1) {
myservo.write(pos);
delay(10);
}
for (int pos = 130; pos >= 50; pos -= 1) {
myservo.write(pos);
delay(10);
}
}

void put_off_fire() {
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
digitalWrite(pump, HIGH);
sweepServo(); // Sweep the servo while extinguishing the fire
digitalWrite(pump, LOW);
}

void loop() {
// Read the smoke level from the MQ-2 smoke sensor
int smokeLevel = analogRead(smokeSensorPin);

// Check if the smoke level exceeds the defined threshold
if (smokeLevel > smokeThreshold) {
    put_off_fire();
    return; // Stop execution and put out the fire
}

myservo.write(90); // Center the servo

int leftSensor = digitalRead(Left);
int rightSensor = digitalRead(Right);
int forwardSensor = digitalRead(Forward);

if (leftSensor && rightSensor && forwardSensor) {
    // Move forward
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
} else {
    // Stop and adjust movement based on sensor inputs
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);

    if (leftSensor == LOW) {
        // Turn left
        digitalWrite(LM1, HIGH);
        digitalWrite(LM2, LOW);
        digitalWrite(RM1, HIGH);
        digitalWrite(RM2, HIGH);
    }

    if (rightSensor == LOW) {
        // Turn right
        digitalWrite(LM1, HIGH);
        digitalWrite(LM2, HIGH);
        digitalWrite(RM1, HIGH);
        digitalWrite(RM2, LOW);
    }
}

}

and this plain error keeps popping up with no other specific information on the error:

exit status 1

Compilation error: exit status 1

It works, it now shows a specific error. But I can't believe with these so many errors:

FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\sketch\firefighting_Robot.ino.cpp -o nul
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
  -> candidates: [Wire@1.0]
C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\sketch\firefighting_Robot.ino.cpp -o nul
Alternatives for Servo.h: [Servo@1.2.1]
ResolveLibrary(Servo.h)
  -> candidates: [Servo@1.2.1]
C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\sketch\firefighting_Robot.ino.cpp -o nul
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\Wire.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\utility\twi.c
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\avr\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\mbed\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\megaavr\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\nrf52\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\renesas\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\sam\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\samd\Servo.cpp
Using cached library dependencies for file: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src\stm32f4\Servo.cpp
Generating function prototypes...
C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard -IC:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\ACER\AppData\Local\Arduino15\libraries\Servo\src C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\sketch\firefighting_Robot.ino.cpp -o C:\Users\ACER\AppData\Local\Temp\1604247782\sketch_merged.cpp
C:\Users\ACER\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\ACER\AppData\Local\Temp\1604247782\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\ACER\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\ACER\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\ACER\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "-IC:\\Users\\ACER\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\Wire\\src" "-IC:\\Users\\ACER\\AppData\\Local\\Arduino15\\libraries\\Servo\\src" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\sketch\\firefighting_Robot.ino.cpp" -o "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\sketch\\firefighting_Robot.ino.cpp.o"
Compiling libraries...
Compiling library "Wire"
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Wire\utility\twi.c.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Wire\Wire.cpp.o
Compiling library "Servo"
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\mbed\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\stm32f4\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\megaavr\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\renesas\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\sam\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\samd\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\nrf52\Servo.cpp.o
Using previously compiled file: C:\Users\ACER\AppData\Local\Temp\arduino\sketches\515A562CCEA0025F48D8DA2B14AA3C14\libraries\Servo\avr\Servo.cpp.o
Compiling core...
Using precompiled core: C:\Users\ACER\AppData\Local\Temp\arduino\cores\arduino_avr_uno_b4351cbb06f1e9934c5c3eb73540fcc6\core.a
Linking everything together...
"C:\\Users\\ACER\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14/firefighting_Robot.ino.elf" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\sketch\\firefighting_Robot.ino.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Wire\\Wire.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Wire\\utility\\twi.c.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\avr\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\mbed\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\megaavr\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\nrf52\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\renesas\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\sam\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\samd\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14\\libraries\\Servo\\stm32f4\\Servo.cpp.o" "C:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14/..\\..\\cores\\arduino_avr_uno_b4351cbb06f1e9934c5c3eb73540fcc6\\core.a" "-LC:\\Users\\ACER\\AppData\\Local\\Temp\\arduino\\sketches\\515A562CCEA0025F48D8DA2B14AA3C14" -lm

Using library Wire at version 1.0 in folder: C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire 
Using library Servo at version 1.2.1 in folder: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo 
exit status 1

Compilation error: exit status 1

How to fix this?

P.S. I'm new to Arduino coding

Welcome to software engineering! Actually, 95% of that output aren't errors, but just messages about what the compiler and linker are doing. The actual error isn't in there.

How does this bit look like on your end?
image

Btw, I copied your code from post #1 and compiled it for Arduino UNO, but see no errors. It compiles just fine. I have not tested if it works.

Yes, I already did that in the verbose thing, but it still keeps on popping up :((

How did you manage to run my code without error?

Hm, looks OK.

I don't know; I just copy-pasted your code into my Arduino, selected the Arduino UNO board, hit 'Verify' and it compiled without issue.

I'm sorry, I don't recognize this issue. I'm thinking along the lines of maybe a permissions issue where the compiler fails to write certain files to the disk, or maybe somehow a corrupted Arduino IDE/platform installation.

Is this laptop managed by an IT department or school, with limited access rights or something?

Are you trying to run this out of a zipped file? The errors show the IDE looks at your sketch for libraries, but the libraries are not found.

Good catch.

@roxx69 if you use the Explorer to navigate to this folder, what's in there: C:\Users\ACER\AppData\Local\Arduino15\libraries\Servo
You should see something like this:


And the folder should exist in the first place!

The libraries are found; see e.g. the following from the log

I would start by deleting that directory or cleaning out the complete Sketches directory and see if that solves the problem.

This is my interpretation of "not found"... rather than using a library, it is creating one. I would then look for my libraries in the IDE.

It's compiling one :wink: And the output shows that it's using one that was compiled before.

Thanks guys for the help. My ide works perfectly fine now. But I am having another problem when compiling the code, the error that now pops is "Failed uploading: no upload port provided"

And when I try to access the port menu, it is not accessible:
440955444_457167593365815_9221213681072208327_n

how to fix?

Can you indicate which reply actually helped you; this is for others who encounter the same problem.

Did you ever try to start with e.g. the blink example and could you upload that (in the past)?
What does Windows device manager think of your board?

Hmm this might seem an easy way out (real), but I deleted my arduino ide and install it again lol

No. I haven't since I'm just new to this. So I'm still new on troubleshooting this one

If you had used < CODE > tags, your sketch would appear like below:

#include <Wire.h>
#include <Servo.h>

Servo myservo;

#define Left 8
#define Right 9
#define Forward 10
#define LM1 2
#define LM2 3
#define RM1 4
#define RM2 5
#define pump 6
#define smokeSensorPin A0
#define smokeThreshold 300

void setup()
{
  pinMode(Left, INPUT);
  pinMode(Right, INPUT);
  pinMode(Forward, INPUT);
  pinMode(LM1, OUTPUT);
  pinMode(LM2, OUTPUT);
  pinMode(RM1, OUTPUT);
  pinMode(RM2, OUTPUT);
  pinMode(pump, OUTPUT);

  myservo.attach(11);
  myservo.write(90);
}

void sweepServo()
{
  for (int pos = 50; pos <= 130; pos += 1)
  {
    myservo.write(pos);
    delay(10);
  }
  for (int pos = 130; pos >= 50; pos -= 1)
  {
    myservo.write(pos);
    delay(10);
  }
}

void put_off_fire()
{
  digitalWrite(LM1, LOW);
  digitalWrite(LM2, LOW);
  digitalWrite(RM1, LOW);
  digitalWrite(RM2, LOW);
  digitalWrite(pump, HIGH);
  sweepServo(); // Sweep the servo while extinguishing the fire
  digitalWrite(pump, LOW);
}

void loop()
{
  // Read the smoke level from the MQ-2 smoke sensor
  int smokeLevel = analogRead(smokeSensorPin);

  // Check if the smoke level exceeds the defined threshold
  if (smokeLevel > smokeThreshold)
  {
    put_off_fire();
    return; // Stop execution and put out the fire
  }

  myservo.write(90); // Center the servo

  int leftSensor = digitalRead(Left);
  int rightSensor = digitalRead(Right);
  int forwardSensor = digitalRead(Forward);

  if (leftSensor && rightSensor && forwardSensor)
  {
    // Move forward
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
  } else {
    // Stop and adjust movement based on sensor inputs
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);

    if (leftSensor == LOW)
    {
      // Turn left
      digitalWrite(LM1, HIGH);
      digitalWrite(LM2, LOW);
      digitalWrite(RM1, HIGH);
      digitalWrite(RM2, HIGH);
    }

    if (rightSensor == LOW)
    {
      // Turn right
      digitalWrite(LM1, HIGH);
      digitalWrite(LM2, HIGH);
      digitalWrite(RM1, HIGH);
      digitalWrite(RM2, LOW);
    }
  }
}

Your sketch is compiled in in my IDE 1.8.19, and it is also uploaded ok in Arduino UNO.

Hey, it worked! I probably would have done the same. Good call.

OK, with the UNO plugged in, can you upload a screenshot of your Device Manager (Opening Windows Device Manager - Windows 10 | Verizon) and expand in particular the USB section towards the bottom:
image
Please also expand the COM section (if available):
image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.