-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine_Tracking.cpp
More file actions
57 lines (46 loc) · 1.08 KB
/
Line_Tracking.cpp
File metadata and controls
57 lines (46 loc) · 1.08 KB
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
#include <Arduino.h>
#include "Freenove_4WD_Car_For_Pico_W.h"
#include "Line_Tracking.h"
#define SPEED_LV1 ( -30 )
void tracker_setup()
{
Track_Setup(); //Trace module initialization
Motor_Setup(); //Motor initialization
}
float Previous_Left = 0;
float Previous_Right = 0;
void track_line_move()
{
delay(1);
Track_Read();
switch (sensorValue[3])
{
case 2: //010
Previous_Left = SPEED_LV1;
Previous_Right = SPEED_LV1;
break;
case 5: //101
break;
case 0: //000
break;
case 7: //111
Previous_Left = SPEED_LV1;
Previous_Right = SPEED_LV1;
break;
case 4: //100
Previous_Left = -SPEED_LV1;
Previous_Right = SPEED_LV1;
break;
case 6: //110
break;
case 1: //001
Previous_Left = SPEED_LV1;
Previous_Right = -SPEED_LV1;
break;
case 3: //011
break;
default:
break;
}
Motor_M_Move(Previous_Left, Previous_Left, Previous_Right, Previous_Right);
}