-
Notifications
You must be signed in to change notification settings - Fork 3
/
move.c
47 lines (46 loc) · 1.11 KB
/
move.c
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
void move()
{
senser_value_L = ADC_Conversion(3); //Getting data of Left WL Sensor
senser_value_C = ADC_Conversion(2); //Getting data of Center WL Sensor
senser_value_R = ADC_Conversion(1); //Getting data of Right WL Sensor
if ((senser_value_L > Threshold) && (senser_value_C < Threshold))
{
forward();
left_motor = 200;
right_motor = 255;
velocity(left_motor,right_motor);
flag = 1;
}
else if ((senser_value_R > Threshold) && (senser_value_C < Threshold))
{
forward();
left_motor = 255;
right_motor = 200;
velocity(left_motor,right_motor);
flag = 2;
}
else if ((senser_value_C > Threshold) && (senser_value_L < Threshold) && (senser_value_R < Threshold))
{
forward();
left_motor = 255;
right_motor = 255;
if (flag == 1) {
velocity(left_motor, right_motor);
}
else {
velocity(right_motor, left_motor);
}
}
else if ((senser_value_R < Threshold) && (senser_value_C < Threshold) && (senser_value_L < Threshold))
{
forward();
left_motor = 170;
right_motor = 255;
if (flag == 1) {
velocity(left_motor, right_motor);
}
else {
velocity(right_motor, left_motor);
}
}
}