35 lines
570 B
C++
35 lines
570 B
C++
#ifndef SERVOMOTOT_COMPONENT_H
|
|
#define SERVOMOTOT_COMPONENT_H
|
|
|
|
#include <Servo.h>
|
|
|
|
enum Position {
|
|
LEFT,
|
|
MIDDLE,
|
|
RIGHT
|
|
};
|
|
|
|
class ServoMotorComponent
|
|
{
|
|
public:
|
|
ServoMotorComponent(int PIN, unsigned long updatePeriod = 100, float step = 0.1);
|
|
void setDesiredPosition(Position desiredPosition);
|
|
bool isConnected();
|
|
void refresh();
|
|
|
|
private:
|
|
int PIN;
|
|
float currentPosition;
|
|
float desiredposition;
|
|
Servo myservo;
|
|
unsigned long lastUpTime;
|
|
unsigned long updatePeriod;
|
|
float step;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SERVOMOTOT_COMPONENT_H
|