-
Notifications
You must be signed in to change notification settings - Fork 0
/
servoMotor.cpp
40 lines (34 loc) · 1.26 KB
/
servoMotor.cpp
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
/******************************************************************************
* *
* Program : FileLogger *
* *
* FILE : servoMotor.cpp *
* *
* Date : 28 / 05 / 2021 *
* *
* Programmers : Team Software "TORQ" *
* *
******************************************************************************/
#include "servoMotor.h"
ServoMotor::ServoMotor(byte m_pin)
{
pin = m_pin;
pos = 92;
}
void ServoMotor::init()
{
servo.attach(pin);
}
void ServoMotor::rotate_left(int r_angle)
{
servo.write(pos + r_angle);
}
void ServoMotor::rotate_right(int r_angle)
{
servo.write(pos - r_angle);
}
void ServoMotor::reset()
{
pos = 90;
servo.write(pos);
}