Servo example program & errors

When I load the “Sweep” program from the Examples folder in IDE 1.6.13, I get a whole host of errors.

/* 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;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

Errors:

Arduino: 1.6.13 (Windows 7), Board: "Arduino/Genuino Uno"

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `ServoCount'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `__vector_11'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::Servo()'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::Servo()'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::attach(int, int, int)'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::attach(int)'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::detach()'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::writeMicroseconds(int)'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::write(int)'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::readMicroseconds()'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::read()'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `Servo::attached()'

libraries\Servo\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Yesterday I did the same thing and it was running fine. Now it wont compile. I can’t say I am impressed - it seems like the whole Arduino software system hangs by a thread and the error messages aren’t much help!

It is very disappointing that the Arduino developers seem to give no thought to backwards compatibility. Your program compiles fine with IDE 1.6.3 which is the version I use.

There is no problem having multiple versions of the IDE on your PC.

...R

All the errors I am getting seem to relate to 'multiple definition' "first defined in Servo.cpp.o"

When I search my computer drive, I find a file called "Servo.cpp.o" in various folders such as avr (C:\users\Dianne\AppData\Local\Temp\arduino_build_876669\libraries\Servo

All these files were created today and I don't know how they got there!

I deleted all occurrences of Servo.cpp.o, scanned again, and they were all gone. When I compile the "Sweep" example program, they all come back again so obviously the compiler id creating them and then giving multiple definition errors !!! WTF??!!

so obviously the compiler id creating them

Of course it is. The clue is the fact that it is a .o file.

The obvious question is why are there multiple Servo.cpp files on your computer that are being compiled.

I don’t know where they are coming from! This #### sketch worked fine yesterday!

Servo.cpp is appearing in 5 different places (see attached) and Servo.cpp.o is created at compile.

I downgraded to IDE 1.6.3 and don't get any errors when compiling any more but the code doesn't execute either.

Frustrated? Yup! I have to leave this for awhile before I start smashing things!

but the code doesn't execute either.

Proof? Add some Serial.print() statements, and Serial.begin() to setup() if it isn't already there. I'm sure that you'll see that it DOES execute. How are you actually connecting the servos to the Arduino and external power supply?

You are correct - bad connection in a servo wire.

Unfortunately I am now 1/2 way through switching back to 1.6.13 :(

After uninstalling version 1.6.3, I completely reinstalled 1.6.13 (after copying my sketches to a safe place) and started fresh.

I copied my sketches back into 1.6.13 and all the errors are gone on the Sweep program.

We need an emoticon for "pulling your hair out"!