Pages: [1]   Go Down
Author Topic: Compile error for Servo.h  (Read 1984 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My Arduino Servo example (sweep) worked without the arduino library.
Here's the exact code in my program:

Code:
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
 
Servo myservo;  // create servo object to control a servo
                // 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
  }
}

I downloaded the Servo library and suddenly everything stopped working.
I got these errors:

Code:







C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp: In member function 'uint8_t Servo::attach(int)':
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:28: error: 'digitalWrite' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:29: error: 'OUTPUT' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:29: error: 'pinMode' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp: In member function 'void Servo::write(int)':
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:52: error: 'clockCyclesPerMicrosecond' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp: In static member function 'static void Servo::refresh()':
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:74: error: 'millis' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:107: error: 'digitalWrite' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:109: error: 'TCNT0' was not declared in this scope
C:\Users\Misha_2\Documents\Arduino\libraries\Servo\Servo.cpp:124: error: 'digitalWrite' was not declared in this scope

I deleted the Servo library and reverted the state of my Arduino folder to the same way it was just before I got the library, and it still didn't work.
'TCNT0' is not in any files in the Servo library or in the Arduino folder as far as I can see.
Does anyone know how to fix this problem?
Thanks!
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What version of arduino are you running? if its not the latest version get the latest version and see if it works
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't you have to have at the very start of your sketch a:

#include <Servo.h>

Also you don't have to down load a servo library, it's included in the current IDE. Possibly you have replaced the correct one with an older incorrect library?


Lefty
« Last Edit: January 04, 2013, 07:25:15 pm by retrolefty » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yea thats what I was thinking. But he has to have servo.h included because the errors are from servo.cpp
Logged

Belgium
Online Online
Edison Member
*
Karma: 68
Posts: 1920
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have seen wierd things with the latest versions (1.0.1 and later) and "special libraries"
It happened again after I described it in this post http://arduino.cc/forum/index.php/topic,135457.msg1018947.html#msg1018947
Renaming the folder only helps for the run you are doing. Next time you start the Arduino IDE it piced it up again. So the problem is not name related.

Not sure it is related to the problem of the PO but it does sound a bit like it.

Anyway posting the full sketch should be the starting point.

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had this same problem and as others have mentioned, it turned out to be that I had downloaded a servo library, so to make my code work all I had to do was delete the servo library and restart the arduino app and everything was happy again!
Logged

Pages: [1]   Go Up
Jump to: