-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.c
80 lines (70 loc) · 868 Bytes
/
program.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
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
#include<REG52MOD.h>
#define forward 0x05;
#define right 0x01;
#define left 0x04;
#define lineright P1_6
#define lineleft P1_1
#define mleft P1_2
#define mright P1_5
#define mmright P1_4
#define mmleft P1_3
void main(void)
{
P1=0xff;
P2=0x00;
while (1)
{
if(lineleft==0,mleft==0,mmleft==0)
{
while (lineright==1)
{
P2=right;
}
if (mmright==1)
{
P2=right;
}
else
{
P2=forward;
}
}
if (lineright==0,mright==0,mmright==0)
{
while (lineleft==1)
{
P2=left;
}
if (mmleft==1)
{
P2=left;
}
else
{
P2=forward;
}
}
if (lineright==0,mright==0,mmright==0,lineleft==0,mmleft==0)
{
while (mleft==1)
{
P2=left;
}
}
else
{
P2=forward;
}
if (lineright==0,mmright==0,lineleft==0,mleft==0,mmleft==0)
{
while (mright==1)
{
P2=right;
}
}
else
{
P2=forward;
}
}
}