-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotor.h
62 lines (43 loc) · 1.5 KB
/
motor.h
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
55
56
57
58
59
60
61
62
#ifndef Motor_h
#define Motor_h
#include "master.h"
#include "Arduino.h"
#include <SPI.h>
/************** Start Motor Class Definition ************/
class Motor : public Master
{
/************** Start Public Functions ************/
public:
Motor (); // constructor
// initialize pins for the motor system
void pins(int xPin, int yPin, int slavePin, int leftMotorRelay, int rightMotorRelay);
// main function for motors
void readMotorsInputAndTurn();
/************** End Public Functions ************/
/************** Start Private Functions ************/
private:
// class members
int _lastRegisteredSpeedRight;
int _lastRegisteredSpeedLeft;
int _speedLeftMotor;
int _speedRightMotor;
int _xPin;
int _yPin;
int _slavePin;
int _leftMotorRelay;
int _rightMotorRelay;
static int _marginErrorNumber;
// testing function for input
void _testInputValues(int upDown, int leftRigh);
// send movement signals to the motors
void _digitalPotWrite(int address, int value);
// get user input and move
void _figureOutDirectionEngine(int y, int x);
// turn on/off relayes to allow going backwards
void _relaySwitches();
//a helper function to smooth the motor movement
void _rampUp(int channel, int lastRegisteredSpeed, int currentSpeed);
/************** End Private Functions ************/
};
/************** End Motor Class Definition ************/
#endif