Keep getting Compilation error: Error: 2 UNKNOWN: exit status 1

I am trying to modify Arduino's servo "sweep" sketch, however I can't seem to get it to compile and upload to my Arduino Uno. Here's the original sweep code:

/* Sweep
by BARRAGAN http://barraganstudio.com
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;

int pos = 0;

void setup() {
myservo.attach(9);
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) {
// in steps of 1 degree
myservo.write(pos);
delay(15);
}
for (pos = 180; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(15);
}
}

And then I keep getting the same error message,

Using board 'uno' from platform in folder: /Users/username/Library/Arduino15/packages/arduino/hardware/avr/1.8.3
Using core 'arduino' from platform in folder: /Users/username/Library/Arduino15/packages/arduino/hardware/avr/1.8.3
Detecting libraries used...
/Users/username/Library/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 -I/Users/username/Library/Arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino -I/Users/username/Library/Arduino15/packages/arduino/hardware/avr/1.8.3/variants/standard /var/folders/92/my6snt694x91v79jrtn8d7wr0000gn/T/arduino-sketch-9F16DA3B3D42C642BD00EB41C0D1EA72/sketch/sketch_apr27a.ino.cpp -o /dev/null
Alternatives for Servo.h: []
ResolveLibrary(Servo.h)
-> candidates: []
Compilation error: Error: 2 UNKNOWN: exit status 1

I'm not sure how to locate where the error stems from within the code, would anyone be able to help me understand where to find such error and/or identify other reasons as to why the sketch won't compile or upload to the Arduino Uno?

Hi @8pmsunsets. The reason for this error is that you don't have the Servo library installed.

To install it, do this:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus. You'll now see the Library Manager panel open in the sidebar.
  2. In the "Filter your search..." field, type "servo".
  3. Scroll down through the list of search results until you find "Servo by Michael Margolis, Arduino". Click on it.
  4. Click the INSTALL button.
  5. Wait for the installation to finish.

Now try compiling your sketch again.

Is the Servo library not part of the standard IDE installation ?

@pert will be the expert here but the CLI and/or the IDE2.0 don't come with libraries pre-installed.

I know, but this question is not in the IDE 2 topic, so who knows ?

@ 8pmsunsets
Which version of the IDE are you using ?

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