Go Down

Topic: Sweep is not compiling for Microservo SG99 (Read 1 time) previous topic - next topic

kampkoala

Apr 27, 2014, 07:22 pm Last Edit: Apr 27, 2014, 07:30 pm by kampkoala Reason: 1
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
Code: [Select]
// 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

Code: [Select]
'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.
Embarrassingly yours,
 Kamp K.

Robin2

I suspect there is a problem with your installation of the Arduino IDE. In the best of IT traditions, delete it and reinstall it.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

kampkoala

Thanks, Robin.
  That did the trick.  I deleted the app and library folder and and reinstalled fresh, everything is compiling as it should be now! 
Embarrassingly yours,
 Kamp K.

Go Up