-
Notifications
You must be signed in to change notification settings - Fork 0
/
motorFuncs.ino
101 lines (83 loc) · 1.43 KB
/
motorFuncs.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
void run_an_Inch()
{
analogWrite(motor_en_left,255);
analogWrite(motor_en_right,255);
right_forward();
left_forward();
delay(inch);
right_stop();
left_stop();
}
void left_turn()
{
right_forward();
left_stop();
delay(500);
while(mode!=FOLLOWING_LINE)
{
right_forward();
left_stop();
delay(10);
readSensors();
}
}
void right_turn()
{
left_forward();
right_stop();
delay(500);
while(mode!=FOLLOWING_LINE)
{
left_forward();
right_stop();
delay(10);
readSensors();
}
}
void U_turn()
{
left_forward();
right_forward();
delay(200);
left_backward();
delay(180);
while(mode!=FOLLOWING_LINE && mode!=ERR_RIGHT && mode!=ERR_LEFT)
{
right_forward();
left_backward();
delay(10);
readSensors();
}
right_stop();
left_stop();
}
void right_forward()
{
digitalWrite(motor_right_for,HIGH);
digitalWrite(motor_right_back,LOW);
}
void left_forward()
{
digitalWrite(motor_left_for,HIGH);
digitalWrite(motor_left_back,LOW);
}
void right_backward()
{
digitalWrite(motor_right_for,LOW);
digitalWrite(motor_right_back,HIGH);
}
void left_backward()
{
digitalWrite(motor_left_for,LOW);
digitalWrite(motor_left_back,HIGH);
}
void right_stop()
{
digitalWrite(motor_right_for,LOW);
digitalWrite(motor_right_back,LOW);
}
void left_stop()
{
digitalWrite(motor_left_for,LOW);
digitalWrite(motor_left_back,LOW);
}