-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainMotor.cpp
54 lines (47 loc) · 1.64 KB
/
mainMotor.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 : mainMotor.cpp *
* *
* Date : 28 / 05 / 2021 *
* *
* Programmers : Team Software "TORQ" *
* *
******************************************************************************/
#include "mainMotor.h"
MainMotor::MainMotor(byte m_enable_pin, byte m_input_a, byte m_input_b)
{
enable_pin = m_enable_pin;
input_a = m_input_a;
input_b = m_input_b;
rpm = 100;
}
void MainMotor::init()
{
pinMode(enable_pin, OUTPUT);
pinMode(input_a, OUTPUT);
pinMode(input_b, OUTPUT);
}
void MainMotor::set_rpm(int m_rpm)
{
rpm = m_rpm;
}
void MainMotor::rotate_clockwise()
{
digitalWrite(input_a, LOW);
digitalWrite(input_b, HIGH);
analogWrite(enable_pin, rpm);
}
void MainMotor::rotate_anti_clockwise()
{
digitalWrite(input_a, HIGH);
digitalWrite(input_b, LOW);
analogWrite(enable_pin, 500);
}
void MainMotor::rotate_stop()
{
digitalWrite(input_a, LOW);
digitalWrite(input_b, HIGH);
analogWrite(enable_pin, 0);
}