-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.gcb
89 lines (77 loc) · 1.37 KB
/
test.gcb
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
#CHIP 16F887
// Components
#DEFINE MotorL PortB.2
#DEFINE MotorL2 PortB.3
#DEFINE MotorR PortB.4
#DEFINE MotorR2 PortB.5
#DEFINE WallDet1 PortA.0 // D2, AN0
#DEFINE WallDet2 PortA.1 // D3, AN1
#DEFINE LineDet PortA.3 // D5, AN3
#DEFINE FireDet PortA.5 // D7, AN4
#DEFINE FanMotor PortB.1
// LCD display
#DEFINE LCD_IO 4
#DEFINE LCD_RS portd.0
#DEFINE LCD_RW portd.1
#DEFINE LCD_Enable portd.2
#DEFINE LCD_DB4 portd.4
#DEFINE LCD_DB5 portd.5
#DEFINE LCD_DB6 portd.6
#DEFINE LCD_DB7 portd.7
// Pinout
Dir MotorL Out
Dir MotorL2 Out
Dir MotorR Out
Dir MotorR2 Out
Dir LineDet In
Dir WallDet1 In
Dir WallDet2 In
Dir FireDet In
Dir FanMotor Out
// Variables
Dim wallDist as byte
Dim deltaWallDist as byte
Dim fireValue as byte
Dim lineCount as byte
// Void setup
FanMotor = true
LineDet = true
lineCount = 0
// Motors on by default
MotorL = false
MotorR = false
MotorL2 = false
MotorR2 = false
Do
Loop
Sub LeftTurn90
MotorL = false
MotorR = false
wait 300 ms
MotorL = false
MotorL2 = true
MotorR = true
MotorR2 = false
wait 405 ms
// 370 ms
MotorL = false
MotorR = false
MotorL2 = false
MotorR2 = false
wait 300 ms
end sub
Sub RightTurn90
MotorL = false
MotorR = false
wait 300 ms
MotorL = true
MotorL2 = false
MotorR = false
MotorR2 = true
wait 420 ms
MotorL = false
MotorR = false
MotorL2 = false
MotorR2 = false
wait 300 ms
end sub