PDA

View Full Version : Key_in from terminal



iw2fvo
- 24th May 2009, 13:36
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

mackrackit
- 24th May 2009, 17:25
ton = key_in
??

Ioannis
- 25th May 2009, 07:29
No Dave it won't work because debugin reads one byte.

DEC modifier must be used here.

Ioannis

iw2fvo
- 25th May 2009, 07:38
Ioannis,
any code suggestion to enter values from 0 to about 65535 DEC ?
Thanks for the assistance,
Ambrogio

Ioannis
- 25th May 2009, 07:48
See the Debugin 2nd example in the manual.

DEBUGIN [dec key_in]

Ioannis

iw2fvo
- 25th May 2009, 16:15
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