Hi,
I just can't get this right . I want to extend the Arduino library Servo class. I have three tabs in in Arduino 1.0 IDE; 1) the sketch using my class Actuator 2) the header actuator.h file and 3) the body actuator.cpp file. Problem is that compilation fails and compiler returns
In file included from actuator.cpp:1:
actuator.h:6: error: expected class-name before '{' token
What's wrong with my code?
The skecth
#include "actuator.h"
Actuator myservo; // create Actuator object to control a servo
int pos = 1500;
void setup()
{
Serial.begin(9600);
myservo.attach(6); // attaches the servo on pin 6
}
void loop()
{
if ( Serial.available() ) {
pos = Serial.parseInt();
myservo.set(pos);
}
delay(15);
}
actuator.h
#ifndef ACTUATOR_H
#define ACTUATOR_H
#include "Arduino.h"
#include <Servo.h>
class Actuator :
public Servo {
public :
String a_string;
void set(int);
void attach(int);
};
#endif
actuator.cpp
#include "actuator.h"
void Actuator::set(int i) {
// set position
}
void Actuator::attach(int i) {
// attach pin
}