Go Down

Topic: Arduino MegaServo library doesn't work (Read 2040 times) previous topic - next topic

SpaceOne

Feb 16, 2013, 03:24 pm Last Edit: Feb 16, 2013, 03:32 pm by SpaceOne Reason: 1
Arduino MegaServo library doesn't work.
I downloaded the MegaServo library from http://playground.arduino.cc/Code/MegaServo  in arduino-1.0.1\libraries\MegaServo if I add the library shows this errors.
Why?

Quote

D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: In function 'void handle_interrupts(servoTimer_t, volatile uint16_t*, volatile uint16_t*)':
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:96: error: 'LOW' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:96: error: 'digitalWrite' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:103: error: 'HIGH' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:103: error: 'digitalWrite' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:107: error: 'clockCyclesPerMicrosecond' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: At global scope:
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:169: error: 'boolean' does not name a type
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: In constructor 'MegaServo::MegaServo()':
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:205: error: 'clockCyclesPerMicrosecond' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: In member function 'uint8_t MegaServo::attach(int, int, int)':
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:219: error: 'OUTPUT' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:219: error: 'pinMode' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:226: error: 'isTimerActive' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: In member function 'void MegaServo::write(int)':
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:247: error: 'byte' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:247: error: expected `;' before 'channel'
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:248: error: 'channel' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:251: error: 'map' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:258: error: 'clockCyclesPerMicrosecond' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: In member function 'int MegaServo::read()':
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:273: error: 'map' was not declared in this scope
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp: In member function 'int MegaServo::readMicroseconds()':
D:\Program Files\arduino-1.0.1\libraries\MegaServo\MegaServo.cpp:280: error: 'clockCyclesPerMicrosecond' was not declared in this scope

PaulS

Quote
I downloaded the MegaServo library in arduino-1.0.1\libraries\MegaServo if I add the library shows this errors.

The folder you put the code in is for core libraries. MegaServo is NOT a core library. Put it where it belongs, in the libraries folder of your sketch directory.

A link to where you downloaded from would be useful, too, for people that understand how to download and install libraries properly to reproduce the problem, if any.

I'd guess, though, that the library has not been upgraded for use on 1.0+.

SpaceOne

You are right, I  put the MegaServo library in the sketch directory. 

MegaServo library wasn't updated for the new IDE 1. But I replaced in MegaServo.cpp  #include <WProgram.h> with  #include <Arduino.h> and it compiles.

You don't need to install this library if you are using Arduino 0017 or higher... It's included in the Arduino IDE and renamed to servo.h.
http://playground.arduino.cc/Code/MegaServo

Quote
The library (renamed to Servo) is distributed with Arduino releases from 0017, see the Arduino servo library reference for details. You already have this code if you are using the servo library from release 0017 or later.
www.bajdi.com

Go Up