Go Down

Topic: Librairies in librairies (Read 274 times) previous topic - next topic


Hello everyone.

I'm trying to make my own servo library using the Servo.h library. So I created a  Servo_me.h in a libraries folder in sketchbook. Here is my code (it's really an easy code. The class Motor is another class that I've made in order to control motor through a H-bridge.

Code: [Select]
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#include <WProgram.h>
#include <pins_arduino.h>

#ifndef _SER_H
#define _SER_H
#include <Servo.h>
#include "Motor.h"

#define DEVICE (0x53)

class Servo_me : public Motor{
protected :
int pin;
Servo ser;
public :
Servo_me(int p1, int p2, int pin) : Motor(p1, p2), pin(pin){ser.attach(pin);};
Servo_me(int p1, int p2, int pin, int min, int max) : Motor(p1, p2), pin(pin){ser.attach(pin,min,max);};
void write(int deplacement){this->write(deplacement);}


The thing is I get this error :
In file included from Walking.ino:1:0:
/home/Malcolm/sketchbook/libraries/Motor/Servo_me.h:10:23: fatal error: Servo.h: No such file or directory
compilation terminated.

And I don't know why the IDE is not able to find Servo.h since I #include it...

Any idea ? =/


You have to include the Servo.h in the main sketch as well.  Without that the IDE doesn't know to go and look for it.
Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10


OK thanks.

I'll try it later today =)

Go Up