-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServoController.h
More file actions
49 lines (36 loc) · 922 Bytes
/
ServoController.h
File metadata and controls
49 lines (36 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <Servo.h>
class ServoController {
private:
static const int MOVE_INCR = 2;
static const int MOVE_DELAY = 50;
const int pwm_pin;
const int default_pos;
int position;
int max_pos;
int min_pos;
Servo servo;
public:
ServoController(int pwm_pin, int default_pos);
ServoController(int pwm_pin, int default_pos, int min_pos, int max_pos);
void setup();
void go_home();
void set_position(int new_position);
void change_position(int change);
bool at_limit();
int get_position();
};
// Two servos stacked on top of eachother to provide 360 degrees of rotation
class StackedServos {
private:
ServoController duplicated_servo;
int position;
int default_rotation;
public:
StackedServos(int duplicated_pin, int default_pos);
void setup();
void go_home();
void set_position(int new_position);
void change_position(int change);
int get_position();
};