27.01.2015 Views

titus-larsen-titus-1981-apple-interfacing

titus-larsen-titus-1981-apple-interfacing

titus-larsen-titus-1981-apple-interfacing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

sensor. Of course, you will have to determine the corresponding key<br />

·<br />

codes.<br />

We used approximately 10-second periods, for test purposes, with<br />

2-second yellow periods. The program that we used is listed for you:<br />

10 A = 0: P = 49318<br />

20 POKE P, 222<br />

30 FOR R = 0 TO 10<br />

40 FOR T = 0 TO 770: NEXT T<br />

50 NEXT R<br />

55 Z = PEEK(49168)<br />

60 IF PEEK(49152) = 197 GOTO 80<br />

70 GOTO 60<br />

80 Z = PEEK(49168): POKE P, 238<br />

90 FOR R = 1 TO 2<br />

100 FOR T = 0 TO 770: NEXT T<br />

110 NEXT R<br />

120 POKE P, 243<br />

130 FOR R = 0 TO 1000<br />

150 IF PEEK(49152) = 205 THEN 190<br />

170 NEXT R<br />

180 GOTO 210<br />

190 Z = PEEK(49168): A A+l<br />

200 IF A < 5 THEN 170<br />

210 POKE P, 245<br />

220 FOR R = l TO 2<br />

230 FOR T = 0 TO 770: NEXT T<br />

240 NEXT R<br />

250 GOTO 10<br />

You should note that the keyboard Hag is reset before it is tested at<br />

line 60. This clears any keyboard entries that are made during the<br />

first IO-second period. You can remove this step, if you want the<br />

Elm Street sensor to "remember" any cars that trip it during this<br />

period.<br />

The flag-detecting step at line 150 has been embedded in the overall<br />

timing loop. This means that the flag is always being checked,<br />

and that these flag-detecting steps must be figured into the overall<br />

delay period. You can do this by testing various values of the delay<br />

constant at line 130.<br />

There are many other things that this program could do. For example,<br />

many intersections have pedestrian control signals, left-hand<br />

tum signals, :flashing lights, and other special features. You could<br />

make the program as complex as you wish. In this situation, the<br />

timing is not particularly critical. It wouldn't really matter if the<br />

cars had to wait an extra second or two while a flag is tested. However,<br />

periods of 10 or 20 seconds could be annoying to d1ivers. Keep<br />

this in mind as you program. In some cases, the time requirements<br />

will be so strict, and the time periods so short, that assembly-language<br />

programming is dictated.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!