Hi, im new here so please dont be angry with me if this a dumm question.
So I want to create a library and inside it to declare servos and attach them.
Kinda like this:
Spider.h:
#ifndef Spider_h
#define Spider_h
#include "Arduino.h"
#include "Servo.h"
class Spider
{
public:
Spider();
void Attach();
private:
};
#endif
Spider.cpp:
#include "Arduino.h"
#include "Servo.h"
#include "Spider.h"
Spider::Spider()
{
Servo SL1A;
Servo SL1B;
Servo SL1C;
}
void Spider::Attach()
{
SL1A.attach(22);
SL1B.attach(23);
SL1C.attach(24);
}
and then be able to do smth like this:
#include <Servo.h>
#include <Spider.h>
Spider X;
void setup()
{
X.Attach();
}
and then i could be able to control the servos like normal servo objects like so:
SL1A.write(90);
Is there a way for this to happen?
Cause I get an error that I havent declared SL1A-B-C in this scope.
Thanks in advance,