-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.ino
138 lines (48 loc) · 2.01 KB
/
notes.ino
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* <- Do not delete
AIDRIVER METHODS:
- mrJonesDriving->rotateRight(200); // speed can be between 0-255
- mrJonesDriving->rotateLeft(200);
- mrJonesDriving->driveForward(200,200); //Make mrJonesDriving drive forward left wheel speed 200 and right wheel speeed 200
- mrJonesDriving->driveBackward(200,200);
- mrJonesDriving->brake(); // Make mrJonesDriving stop instantly
- mrJonesDriving->read(); Returns the measurement from the ultrasonic ranger in mm
ARDUINO METHODS:
- delay(1000); // Ardunio stops processing and continues in set state for duration in milliseconds 1000 = 1 second
- Serial.println(mrJonesDriving->read()); // Prints ranger state to the serial monitor
- Serial.println("Hello World"); //Prints something to the serial monitor
CONTROL STRUCTURES
if (true){
Serial.println("This is true")
}
if (true){
Serial.println("This is true")
} else {
Serial.println("This is false")
}
while (true) {
mrJonesDriving->driveForward(200,200);
}
Testing code:
#include "AIDriver.h"
// Declare a pointer to a AIDriver object
AIDriver *mrJonesDriving;
void setup(){ // sets up once as the program starts
//Instantiate a two wheeled to the pointer 'mrJonesDriving'
mrJonesDriving = new AIDriver();
}
void loop(){ // loops continuously 50 times a second
// Read the distanceRanger ulstrasonic sensor and return the object distance in mm
Serial.println(mrJonesDriving->read());
//obj->doSomething(); in this case make the object mrJonesDriving rotate to the right at a speed of 200
mrJonesDriving->rotateRight(125); // speed can be between 0-255
// wait 2000 milliseconds or 2 seconds
delay(2000);
mrJonesDriving->rotateLeft(125);
delay(2000);
//Make mrJonesDriving drive forward left wheel speed 200 and right wheel speeed 200
mrJonesDriving->driveForward(125,125);
delay(2000);
mrJonesDriving->driveBackward(125,125);
delay(2000);
}
*/// <- Do not delete