forked from sudar/DCMotorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDCMotorBot.h
72 lines (56 loc) · 1.67 KB
/
DCMotorBot.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
/**
DCMotorBot - A simple library to control bots made using 2 simple DC Motors
http://hardwarefun.com/projects/dc-motor-bot
*/
/*
* Copyright 2012 Sudar Muthu (email : [email protected])
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <[email protected]> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer or coffee in return - Sudar
* ----------------------------------------------------------------------------
*/
//TODO: Add speed control using PWM
#ifndef DCMotorBot_H
#define DCMotorBot_H
// Compatibility for Arduino 1.0
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class DCMotorBot {
public:
// constructor
DCMotorBot(); // empty constructor
DCMotorBot(byte el, byte e2, byte I1, byte I2, byte I3, byte I4, int delay); // full constructor
void setEnablePins(byte el, byte e2);
void setControlPins(byte I1, byte I2, byte I3, byte I4);
void setDelay(int delay);
void setSpeed(int speed);
// movement functions
void start();
void moveForward();
void moveBackward();
void turnLeft();
void turnRight();
void stop();
// movement functions for front steering
void goForward();
void goBackward();
void steerLeft();
void steerRight();
private:
int mDelay; // delay while switching
int mSpeed; // PWM motor speed
// enable pins
byte mE1;
byte mE2;
// Control Pins
byte mI1;
byte mI2;
byte mI3;
byte mI4;
};
#endif