CH13PR1.LST:

100 REM MOTOR CONTROL DEMONSTRATION
110 PRINT "KEYBOARD CONTROL"
120 PRINT
130 PRINT "G - MOTOR TURNS IN ONE DIRECTION"
140 PRINT "> - MOTOR TURNS IN OPPOSITE DIRECTION"
150 PRINT "S - STOP MOTOR"
155 PRINT :PRINT "X - EXIT PROGRAM"
160 B=0
170 A=PEEK(764)
180 IF A=54 THEN GOSUB 1000:GOTO 170
190 IF A=55 THEN GOSUB 2000:GOTO 170
200 GOSUB 3000
210 IF A=22 THEN END
220 GOTO 170
1000 REM TURN MOTOR ON IN ONE DIRECTION
1010 REM CHECK IF THIS HAS ALREADY BEEN DONE
1020 IF B=1 THEN 1100
1030 REM SET DATA LINES FOR OUTPUT
1032 POKE 54018,4B
1034 POKE 54016,3
1036 POKE 54018,52
1040 REM SET FIRST DATA LINE LOCIC LOW TO TURN ON MOTOR
1050 POKE 54016,2
1060 B=1
1100 RETURN
2000 REM TURN ON MOTOR IN OTHER DIRECTION
2010 REM CHECK IF THIS HAS ALREADY BEEN DONE
2020 IF B=2 THEN 2100
2030 REM SET BOTH DATA LINES FOR OUTPUT
2032 POKE 54018,48
2034 POKE 54016,3
2036 POKE 54018,52
2040 REM SET BOTH DATA LINES LOGIC LOW TO TURN ON MOTOR AND REVERSE POLARITY
2050 POKE 54016,0
2060 B=2
2100 RETURN
3000 REM TURN MOTOR OFF
3010 REM CHECK AND SEE IF THIS HAS BEEN DONE
3020 IF B=0 THEN 3100
3030 REM SET BOTH DATA LINE LOGIC HIGH
3040 POKE 54016,3
3050 REM RESET DATA LINES FOR INPUT
3060 POKE 54018,48
3070 POKE 54016,0
3090 POKE 54018,52
3095 B=0
3100 RETURN

Back to previous page