Need Help with Servo.h

I'm trying to use the servo library for the first time. When I try to compile my sketch and there is a problem with Servo.h

Error:
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

Bad error line: -2

line 111 of stdlib.h is:

extern int abs(int __i) ATTR_CONST;

I'm open to all suggestions or even methods for troubleshooting.
Thank you!

Maybe you should also post your sketch?

:slight_smile:

sketch is as follows:

#include <Servo.h>

int SERVOPIN = 9;
Servo servo;

void setup()
{
servo.attach(SERVOPIN);
}

void servoSweep(int final, int hold)
{
for(int pos = 0; pos < final; pos += 1)
{
servo.write(pos);
delay(20);
}
delay(hold);
for(int pos = final; pos >= 0; pos -= 1) {
servo.write(pos);
delay(20);
}
}

void loop()
{
servoSweep(20, 3000);
delay(5000);
}

No problem with 0017 or 0018.
What are you using?

Hey Awol,
I'm using 0018.
Thanks for taking a look!

Still no luck getting servo.h to compile. Does anyone out there have troubleshooting suggestions for broken libraries? Or a link to someone that has covered this topic? Thanks much!

Make sure your servo library is in the right place. You click on the hardware folder, then libraries.

It's also important that you have the right board selected. What Arduino do you have?