-
Notifications
You must be signed in to change notification settings - Fork 0
/
driveshaft.cpp
54 lines (47 loc) · 1.79 KB
/
driveshaft.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/******************************************************************************
* *
* Program : FileLogger *
* *
* FILE : driveshaft.cpp *
* *
* Date : 28 / 05 / 2021 *
* *
* Programmers : Team Software "TORQ" *
* *
******************************************************************************/
#include "driveShaft.h"
DriveShaft::DriveShaft(byte m_epin, byte m_inapin, byte m_inbpin, byte m_s_pin) : p_mainMotor(m_epin, m_inapin, m_inbpin), p_servoMotor(m_s_pin)
{
}
void DriveShaft::moveForward(int m_speed)
{
p_servoMotor.reset();
p_mainMotor.set_rpm(m_speed);
p_mainMotor.rotate_clockwise();
}
void DriveShaft::turnLeft(int m_speed, int m_angle)
{
p_servoMotor.reset();
p_servoMotor.rotate_left(m_angle);
p_mainMotor.set_rpm(m_speed);
p_mainMotor.rotate_clockwise();
}
void DriveShaft::turnRight(int m_speed, int m_angle)
{
p_servoMotor.reset();
p_servoMotor.rotate_right(m_angle);
p_mainMotor.set_rpm(m_speed);
p_mainMotor.rotate_clockwise();
}
void DriveShaft::powerStart()
{
p_servoMotor.reset();
p_mainMotor.set_rpm(500);
p_mainMotor.rotate_clockwise();
delay(200);
}
void DriveShaft::stopMovement()
{
p_servoMotor.reset();
p_mainMotor.rotate_stop();
}