INKEY

Top  Previous  Next

Action

Returns the ASCII value of the first character in the serial input buffer.

 

 

Syntax

var = INKEY()

var = INKEY(#channel)

 

 

Remarks

Var

Byte, Integer, Word, Long or String variable.

Channel

The channel number of device

 

If there is no character waiting, a zero will be returned.

 

The INKEY routine can be used when you have a RS-232 interface on your uP.

See the manual for a design of an RS-232 interface.

The RS-232 interface can be connected to a comport of your computer.

 

The INKEY() function only works with the hardware UART, not the software UART.

 

 

See also

WAITKEY

 

 

Example

Dim A As Byte

Do                                 'start loop

A = Inkey()                       'look for character

If A > 0 Then                     'is variable > 0?

  Print A                         'yes , there was a character in the buffer

                                         'so print it

End If

Loop                               'loop forever

 

 

 

Example

$regfile = "80517.dat"

Open "COM2:" For Binary As #1             'open serial channel 1 on 80537

Dim St As Byte

St = Inkey(#1)                           'get key from com2

If St > 0 Then

Printbin #1 , St                       'send to com 2

End If

Close #1