-
Notifications
You must be signed in to change notification settings - Fork 0
/
motorDriver.h
85 lines (81 loc) · 1.39 KB
/
motorDriver.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef __H_MOTOR_DRIVER
#define __H_MOTOR_DRIVER
#include "delayTimer.h"
#define PWM_FREQUENCY 1000 // PWM frequency in Hz
#define MAX_DUTY_CYCLE 100 // Maximum duty cycle value (0-100%)
#define DEFAULT_SPEED 25
#define NO_SPEED 0
#define TURN_ANGLE_SPEED 20
/**
* init the pwm module.
* @param
* @return
*/
void initPWM(void);
/**
* initialize the motor by calling the pwm init.
* @param
* @return
*/
void initMotorDriver(void);
/**
* init the pwm
* @param speedMotor1, speedMotor2
* @return
*/
void setMotorSpeed(int speedMotor1, int speedMotor2);
/**
* move the robot forward.
* @param pin1, pin2
* @return
*/
void run(int pin1, int pin2);
/**
* turn the robot with the given speed.
* @param pin, delay
* @return
*/
void turn(int pin, int delay);
/**
* currently setting the speed of the motors to zero.
* @param
* @return
*/
void brake(void);
/**
* turn left 45 degree.
* @param
* @return
*/
void turn45Left(void);
/**
* turn right 45 degree.
* @param
* @return
*/
void turn45Right(void);
/**
* turn left 90 degree.
* @param
* @return
*/
void turn90(void);
/**
* turn left 135 degree.
* @param
* @return
*/
void turn135(void);
/**
* turn left angle.
* @param
* @return
*/
void turnLeft(int angle);
/**
* turn right angle.
* @param
* @return
*/
void turnRight(int angle);
#endif