-
Key_in from terminal
Good day to all in the forum,
I wrote a simple program using Picbasic Pro that increases or decreases a variable in the program using the "U" or the "D" keys from a PC terminal program like the windows Hyperterminal.
It works but I will like to enter the numeric value to be assigned to the TON variable in my program using the terminal keyboard and tyiping the required value as like as 2568 msec.
This is my presently used code:
DEBUG " ENTER U or D then F to finish "
PIPPO:
DEBUGIN [KEY_IN]
if key_in="U" then ton=ton+100
if ton>10000 then ton=10000
DEBUG 13,10,DEC TON, 13,10
IF KEY_IN="D" THEN TON=TON-100
IF TON<1 THEN TON=1
DEBUG 13,10,DEC TON ,13,10
TOFF=10000-TON
IF KEY_IN="F" THEN GOTO MAIN
GOTO PIPPO
GOTO MAIN
Any help in writing the picbasic code ?
Thanks a lot for any help on the matter.
regards,
Ambrogio
IW2FVO
North Italy
-
-
No Dave it won't work because debugin reads one byte.
DEC modifier must be used here.
Ioannis
-
Ioannis,
any code suggestion to enter values from 0 to about 65535 DEC ?
Thanks for the assistance,
Ambrogio
-
See the Debugin 2nd example in the manual.
DEBUGIN [dec key_in]
Ioannis
-
Thanks,
I was able to write the code.
Here it is:
A VAR PORTB.3
B VAR PORTB.4
TON VAR WORD
TOFF VAR WORD
I VAR WORD
KEY_IN VAR WORD
TON=50 'DEFAULT
TOFF=50 'DEFAULT
LOW A
LOW B
MAIN:
FOR i =0 TO 3000
HIGH A
PAUSEUS TON
LOW A
PAUSEUS TOFF
HIGH B
PAUSEUS TON
LOW B
PAUSEUS TOFF
NEXT I
DEBUG " ENTER TON " ,13,10,7 ' TON ENTER > PROMPT DISPLAYED
DEBUGIN [DEC KEY_IN]
TON= KEY_IN
DEBUG "TON=" ,DEC TON,13,10 ' DISPLAY TON ON TERMINAL
DEBUG ">> GOING ON <<",13,10 ' DISPAY RUNNING ON TERMINAL
GOTO MAIN
Any additional suggestion is appreciated.
Ambrogio
IW2FVO
North Italy