-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar_park.bs2
256 lines (227 loc) · 4.32 KB
/
car_park.bs2
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM7}
ir1 VAR Bit
ir2 VAR Bit
i VAR Byte
j VAR Byte
k VAR Byte
p VAR Byte
a VAR Byte
b VAR Byte
c VAR Byte
x VAR Byte
y VAR Byte
z VAR Byte
l VAR Byte
m VAR Byte
n VAR Byte
us1 VAR Bit
us2 VAR Bit
us3 VAR Bit
us4 VAR Bit
counter VAR Bit
counter = 0
start:
DO
us1 = IN15
us2 = IN14
us3 = IN11
us4 = IN8
FREQOUT 8, 1, 38500
ir1 = IN9
FREQOUT 9, 1, 38500
ir2 = IN10
IF (ir1 =0 AND ir2 =0) THEN
DEBUG HOME, ? ir1
DEBUG LF, ? ir2
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
GOTO start
ELSEIF (ir1 =0 AND ir2 =1) THEN
DEBUG HOME, ? ir1
DEBUG LF, ? ir2
PULSOUT 12, 850
PULSOUT 13, 850
PAUSE 70
GOTO start
ELSEIF (ir1 =1 AND ir2 =0) THEN
DEBUG HOME, ? ir1
DEBUG LF, ? ir2
PULSOUT 12, 650
PULSOUT 13, 650
PAUSE 70
GOTO start
ELSEIF (ir1 =1 AND ir2 =1) THEN
DEBUG LF, ? us1
DEBUG LF, ? us2
DEBUG LF, ? us3
DEBUG LF, ? us4
IF (us1 = 1 AND us2 = 0 AND us3 = 0 AND us4 = 0)THEN
GOTO parking1
ELSEIF (us1 = 0 AND us2 = 1 AND us3 = 0 AND us4 = 0)THEN
GOTO parking2
ELSEIF (us1 = 0 AND us2 = 0 AND us3 = 1 AND us4 = 0)THEN
GOTO parking3
ELSEIF (us1 = 0 AND us2 = 0 AND us3 = 0 AND us4 = 1)THEN
GOTO parking4
ENDIF
ENDIF
LOOP
parking1: ' Going to parking spot 1
FOR i = 1 TO 15
DEBUG LF, ? i
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
FOR j = 1 TO 15
DEBUG LF, ? j
PULSOUT 12, 850
PULSOUT 13, 850
PAUSE 70
NEXT
FOR k = 1 TO 10
DEBUG LF, ? k
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
GOTO finish
parking2: 'Going to parking spot 2
FOR i = 1 TO 15
DEBUG LF, ? i
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
FOR j = 1 TO 13
DEBUG LF, ? j
PULSOUT 12, 650
PULSOUT 13, 650
PAUSE 70
NEXT
FOR k = 1 TO 10
DEBUG LF, ? k
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
GOTO finish
parking3: 'Going to parking spot 3
DO
FREQOUT 8, 1, 38500
ir1 = IN9
FREQOUT 9, 1, 38500
ir2 = IN10
IF(ir1 = 1 AND ir2 = 1 AND counter = 0)THEN
FOR p = 1 TO 4
DEBUG HOME, ? counter
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
DEBUG CLS
GOTO parking3
NEXT
ELSEIF(ir1 = 0 AND ir2 = 0)THEN
counter = 1
DEBUG HOME, ? counter
DEBUG CLS
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
GOTO parking3
ELSEIF(ir1 = 1 AND ir2 = 0)THEN
counter = 1
DEBUG HOME, ? counter
DEBUG CLS
PULSOUT 12, 650
PULSOUT 13, 650
PAUSE 70
GOTO parking3
ELSEIF(ir1 = 0 AND ir2 = 1)THEN
counter = 1
DEBUG HOME, ? counter
DEBUG CLS
PULSOUT 12, 850
PULSOUT 13, 850
PAUSE 70
GOTO parking3
ELSEIF(ir1 = 1 AND ir2 = 1 AND counter = 1)THEN
DEBUG HOME, ? counter
DEBUG LF, ? ir1
DEBUG LF, ? ir2
FOR i = 1 TO 15
DEBUG LF, ? i
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
FOR j = 1 TO 13
DEBUG LF, ? j
PULSOUT 12, 850
PULSOUT 13, 850
PAUSE 70
NEXT
FOR k = 1 TO 10
DEBUG LF, ? k
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
GOTO finish
ENDIF
LOOP
parking4: 'Going to parking spot 4
DO
FREQOUT 8, 1, 38500
ir1 = IN9
FREQOUT 9, 1, 38500
ir2 = IN10
IF(ir1 = 1 AND ir2 = 1 AND counter = 0)THEN
FOR p = 1 TO 4
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
GOTO parking4
NEXT
ELSEIF(ir1 = 0 AND ir2 = 0)THEN
counter = 1
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
GOTO parking4
ELSEIF(ir1 = 1 AND ir2 = 0)THEN
counter = 1
PULSOUT 12, 650
PULSOUT 13, 650
PAUSE 70
GOTO parking4
ELSEIF(ir1 = 0 AND ir2 = 1)THEN
counter = 1
PULSOUT 12, 850
PULSOUT 13, 850
PAUSE 70
GOTO parking4
ELSEIF(ir1 = 1 AND ir2 = 1 AND counter = 1)THEN
FOR i = 1 TO 15
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
FOR j = 1 TO 13
PULSOUT 12, 650
PULSOUT 13, 650
PAUSE 70
NEXT
FOR k = 1 TO 10
PULSOUT 12, 850
PULSOUT 13, 650
PAUSE 70
NEXT
GOTO finish
ENDIF
LOOP
finish:
DEBUG "Finish"