Hey, I'm running an Arduino UNO on 1.0.5 and am trying to load up Sweep sketch for my servo to no avail. And this is directly opening the code from Examplebook.
I get a compiling error of
" 'Servo' does not name a type "
here is the CODE
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
#include <Servo.h>
// a maximum of eight servo objects can be created
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>=1; 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
}
}
and here is my compiling result
'Servo' does not name a type
Sweep:8: error: 'Servo' does not name a type
Sweep.ino: In function 'void setup()':
Sweep:15: error: 'myservo' was not declared in this scope
Sweep.ino: In function 'void loop()':
Sweep:23: error: 'myservo' was not declared in this scope
Sweep:28: error: 'myservo' was not declared in this scope
I'm under the impression that the the compiling wont be affected by whether or not I have the servo plugged in, is that wrong? But I tried both plugged in and not. I suspect it's an issue with my libraries, but I am not sure how to tell.
Thanks for any leads.