-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestDrive.h
100 lines (84 loc) · 2.26 KB
/
testDrive.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
*
*/
#ifndef TESTDRIVE_H
#define TESTDRIVE_H
#include "Arduino.h"
#include "driveControl.h"
const int mtrLeftFwdPin = 9;
const int mtrLeftRevPin = 10;
const int mtrRightFwdPin = 5;
const int mtrRightRevPin = 6;
const float mtrLeftScale = 1.0;
const float mtrRightScale = 1.0;
driveControl botDrive(mtrLeftFwdPin, mtrLeftRevPin, mtrLeftScale,
mtrRightFwdPin, mtrRightRevPin, mtrRightScale);
/*
*
*/
void testDrive() {
static int testNum = 0;
botDrive.loop();
switch (testNum) {
/* Straight FWD */
case 0:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 1");
botDrive.halt(500);
testNum++;
}
break;
/* Straight back */
case 1:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 2");
botDrive.reverse(1000, 70);
testNum++;
}
break;
case 2:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 3");
botDrive.halt(500);
testNum++;
}
break;
/* Turn left */
case 3:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 4");
botDrive.turnLeft(1000, 70);
testNum++;
}
break;
case 4:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 5");
botDrive.halt(500);
testNum++;
}
break;
/* Turn right */
case 5:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 6");
botDrive.turnRight(1000, 70);
testNum++;
}
break;
case 6:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 7");
botDrive.halt(500);
testNum++;
}
break;
case 7:
if (botDrive.getIsIdle()) {
Serial.println("Switching to 0");
botDrive.forward(1000, 70);
testNum = 0;
}
} // switch
}
#endif