U章で利用したプログラム
'------------------------------------------------- ' 温度の設定 '------------------------------------------------- DECLARE SUB INITIALIZE () DECLARE SUB GRAPH () DECLARE SUB END.PROGRAM () CONST PI = 3.141592, XO.T = 12, YO.T = 18, X.TIME = 1, X.VOLT = 57 CONST M.MAX = 60, X.LEN = M.MAX, Y.LEN = 14, END.TIME = 360 CONST SAMPLEING.TIME = 8, LINE.COLOR = 11 CALL INITIALIZE CLS COLOR 7 LOCATE 6, 16: PRINT "===============================================" COLOR 6 LOCATE 7, 16: PRINT " 温度の時間変化を測定します" COLOR 7 LOCATE 8, 16: PRINT "===============================================" COLOR 3 LOCATE 12, 16: PRINT " INPUT1に温度センサを接続して下さい" LOCATE 14, 16: PRINT " SW1をSTDにして下さい" LOCATE 16, 16: PRINT " SW2をBIPにして下さい" COLOR 7 BEEP: COLOR 23 LOCATE 23, 16: PRINT "準備ができましたら,リターンキーを押して下さい" COLOR 7 DO IK$ = INKEY$ LOOP WHILE IK$ = "" START: FLAG = 0 BEEP CALL GRAPH DO BEEP IK$ = INKEY$ IF IK$ = "" THEN GOTO LAST.IF END IF IK = ASC(IK$) IF IK = &H53 OR IK = &H73 OR IK = &HC4 THEN IF FLG = 0 GOTO LAST.IF FLAG = 0: FLG = FLAG CLS 1: CALL GRAPH LOCATE 2, 61: PRINT " " GOTO LAST.IF ELSEIF IK = &H47 OR IK = &H67 OR IK = &HB7 THEN IF FLG = 1 GOTO LAST.IF FLAG = 1: FLG = FLAG T = 0 LOCATE 3, 55: PRINT "開始時刻 ="; : PRINT LEFT$(TIME$, SAMPLING.TIME) GOTO LAST.IF ELSEIF IK = &H45 OR IK = &H65 OR IK = &HB2 THEN CALL END.PROGRAM EXIT DO END IF LAST.IF: LOCATE 4, 55: PRINT "現在時刻 ="; TIME0$ = MID$(TIME$, SAMPLING.TIME, 1) COLOR 2: PRINT LEFT$(TIME$, SAMPLING.TIME): COLOR 7 PRINT #1, "a"; DO LOOP WHILE LOC(1) = 0 DUMMY$ = INPUT$(1, #1) PRINT #1, "i"; LINE INPUT #1, D$: VT = VAL(D$): DUMMY$ = INPUT$(1, #1) VT = 5 * (VT / 256 * 10 - 5) COLOR 3: LOCATE 4, 27: PRINT USING "##.##"; VT / 5: COLOR 7 IF VT > 5 * 1.4 THEN VT = 5 * 1.4 IF VT < 5 * (-1.4) THEN VT = 5 * (-1.4) LINE (XO - 8 * 7 - 1, YO)-(XO - 8 * 8 + 1, YO - 16 * Y.LEN / 2 - 16 * VT), 4, BF LINE (XO - 8 * 7 - 1, YO - 16 * Y.LEN)-(XO - 8 * 8 + 1, YO - 16 * Y.LEN / 2 - 16 * VT - 1), 0, BF IF FLAG = 1 THEN CIRCLE (XO + 8 * T / 6, YO - 16 * Y.LEN / 2 - 16 * VT), 1, 7 PAINT (XO + 8 * T / 6, YO - 16 * Y.LEN / 2 - 16 * VT), 7 END IF DO LOOP WHILE MID$(TIME$, SAMPLING.TIME, 1) = TIME0$ T = T + 1 IF FLAG = 0 GOTO END.LOOP IF T > END.TIME THEN BEGIN.DO: DO IK$ = INKEY$ LOOP WHILE IK$ = "" IK = ASC(IK$) IF IK = &H53 OR IK = &H73 OR IK = &HC4 THEN FLG = 0 GOTO START ELSEIF IK = &H45 OR IK = &H65 OR IK = &HB2 THEN EXIT DO END IF GOTO BEGIN.DO END IF END.LOOP: LOOP WHILE 1 CLS CLOSE #1 END SUB END.PROGRAM CLS CLOSE #1 END SUB SUB GRAPH SHARED XO, YO CLS XO = 3 + 8 * XO.T: YO = 8 + 16 * YO.T LINE (XO - 8 * 7, YO - 16 * (Y.LEN + 1))-(XO - 8 * 7, YO + 16 * 2), 7 LINE (XO - 8 * 8, YO - 16 * (Y.LEN + 1))-(XO - 8 * 8, YO + 16 * 2), 7 FOR I = 0 TO Y.LEN LINE (XO - 8 * 7, YO - 16 * I)-(XO - 8 * 6.5, YO - 16 * I), 7 NEXT CIRCLE (XO - 8 * 7.5, YO - 16 * (Y.LEN + .6)), 8, 7, PI / 2 - .5, PI / 2 + .5 CIRCLE (XO - 8 * 7.5, YO + 16 * 2.5), 8, 7, PI / 2 + .5, 2 * PI CIRCLE (XO - 8 * 7.5, YO - 16 * 2.5), 8, 7, 0, PI / 2 - .5 LINE (XO - 8 * 7, YO)-(XO - 8 * 8, YO), 7 PAINT (XO - 8 * 7.5, YO + 16 * 2.5), 4, 7 LINE (XO - 8 * 7 - 1, YO)-(XO - 8 * 8 + 1, YO), 4 TITLE$ = "min" LINE (XO, YO)-(XO + 8 * X.LEN, YO - 16 * Y.LEN), LINE.COLOR, B FOR I = 1 TO Y.LEN - 1 LINE (XO, YO - 16 * I)-(XO + 8 * X.LEN, YO - 16 * I), LINE.COLOR, , &H8888 NEXT FOR I = 1 TO X.LEN / 10 - 1 LINE (XO + 8 * 10 * I, YO)-(XO + 8 * 10 * I, YO - 16 * Y.LEN), LINE.COLOR, , &H8888 NEXT LINE (XO, YO - 16 * 7)-(XO + 8 * X.LEN, YO - 16 * 7), LINE.COLOR COLOR 6 LOCATE 1, 35: PRINT "温度の時間変化" COLOR 7 LOCATE 4, 14: PRINT "現在の温度 = ℃" COLOR 3 FOR I = 1 TO Y.LEN LOCATE YO.T - I + 1, XO.T - 4: PRINT USING "##.#"; (I - 7) / 5 NEXT LOCATE YO.T - 8, 1: PRINT "温" LOCATE YO.T - 6, 1: PRINT "度" LOCATE YO.T - 4, 1: PRINT "℃" COLOR 2 FOR I = 0 TO X.LEN / 10 LOCATE YO.T + 2, XO.T + 10 * I: PRINT USING "##"; I NEXT LOCATE YO.T + 3, 36: PRINT "経過時間 【"; TITLE$; "】" COLOR 7: LOCATE 23, 15: PRINT "待機 "; : COLOR 6: PRINT "S"; COLOR 7: PRINT "tandby 実行 "; : COLOR 6: PRINT "G"; COLOR 7: PRINT "o"; COLOR 7: LOCATE 23, 60: PRINT "終了 "; : COLOR 6: PRINT "E"; COLOR 7: PRINT "nd"; END SUB SUB INITIALIZE CLS VIEW PRINT 1 TO 24 OPEN "COM1:9600,N,8,1,ASC" FOR RANDOM AS #1 END SUB |