AS IT WOULD APPEAR IN QBASIC
OPEN "COM1: 1200,N,7,2,RS,CS,DS,CD" FOR RANDOM AS #2
A$="D"
PRINT #2, A$
IN$=INPUT$(14, #2)
PRINT IN$
CLOSE #2
END
The line numbers from GWBasic can be eliminated in QBasic.
Com1 refers to which serial port our meter is connected to. If our meter is connected to
Com2, It would be OPEN "COM2:QBasic supports only Com1 or Com2
The above program returns only a single reading. We can add certain functions by using
the timer function to get repeat readings or send the output to the printer or a file. However
to have something real fancy, we must change IN$ from an alphanumeric quantity to a numeric quantity.
If IN$ can be isolated to a numeric quantity, we then can use it a conditional context.
An example of this would be If IN$ > 3 then beep or print the time and the date.
DECLARE SUB TROUBLE ()
CLS
OPEN "COM2: 1200, N, 7, 2, RS, CS, DS, CD" FOR RANDOM AS #2
PRINT TIME$
DO
A$ = "D"
PRINT #2, A$
IN$ = INPUT$(14, #2)
REM PRINT IN$
REM PRINT MID$(IN$, 5, 2)
y$ = MID$(IN$, 3, 11)
REM PRINT y$
u = VAL(y$)
REM PRINT u
IF u < 8 THEN PRINT u: CALL TROUBLE
begin = TIMER
WHILE TIMER < begin + 20
WEND
IF INKEY$ = CHR$(27) THEN EXIT DO
LOOP
CLOSE #2
END
SUB TROUBLE
PRINT "TROUBLE"
PRINT TIME$, DATE$
CLOSE #2
END
END SUB