-
Notifications
You must be signed in to change notification settings - Fork 0
/
movement.h
61 lines (58 loc) · 1.53 KB
/
movement.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
//Movement calibration for RangerBot MAX!
//Do not modify unless you know what you are doing.
#include <PRIZM.h>
PRIZM prizm;
//-------------------------------------------------------------
//Forward
//easiest way to go forward
// in this format: forward(5);
//this makes it go forward about 5 feet.
void forward(float(feet)){
float tDist=feet*1000;
prizm.setMotorPower(1,25);
prizm.setMotorPower(2,-26.5);
delay(tDist);
prizm.setMotorPower(1,0);
prizm.setMotorPower(2,0);
delay(500);
}
//Reverse
//easiest way to go backwards
//in this format :forward(.75);
//this makes it go backward about 9 inches.
void reverse(float(feet)){
float tDist=feet*1000;
prizm.setMotorPower(1,-25);
prizm.setMotorPower(2,27);
delay(tDist);
prizm.setMotorPower(1,0);
prizm.setMotorPower(2,0);
delay(500);
}
//-------------------------------------------------------------
//left
//easiest way to turn left.
//in this format: left(45);
//this makes the robot turn left about 45 degrees
void left(float(degree)){
float tDeg=degree*10;
prizm.setMotorPower(1,25);
prizm.setMotorPower(2,25);
delay(tDeg);
prizm.setMotorPower(1,0);
prizm.setMotorPower(2,0);
delay(500);
}
//right
//easiest way to turn right.
//in this format: right(160);
//this makes the robot turn right about 160 degrees.
void right(float(degree)){
float tDeg=degree*10;
prizm.setMotorPower(1,-25);
prizm.setMotorPower(2,-25);
delay(tDeg);
prizm.setMotorPower(1,0);
prizm.setMotorPower(2,0);
delay(500);
}