ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8172
Скачиваний: 1
© MCS Electronics, 1995-2007
Example
NONE
INKEY
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 |
A constant number that identifies the opened channel if |
software UART mode |
|
If there is no character waiting, a zero will be returned.
Use the IsCharWaiting() function to check if there is a byte waiting.
The INKEY routine can be used when you have a RS-232 interface on your uP. The RS-232 interface can be connected to a comport of your computer.
As zero(0) will be returned when no character is waiting, the usage is limited when the value of 0 is used in the serial transmission. You can not make a difference between a byte with the value 0 and the case where no data is available.
In that case you can use IsCharwaiting to deterimine if there is a byte waiting.
See also
WAITKEY , ISCHARWAITING
Example
'----------------------------------------------------------------------------- |
|
------------ |
: inkey.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demo: INKEY , WAITKEY |
'micro |
: Mega48 |
'suited for demo |
: yes |
'commercial addon needed |
: no |
'-----------------------------------------------------------------------------
------------
$regfile = "m48def.dat" |
' specify the used |
micro |
' used crystal |
$crystal = 4000000 |
|
frequency |
' use baud rate |
$baud = 19200 |
|
$hwstack = 32 |
' default use 32 |
for the hardware stack |
' default use 10 |
$swstack = 10 |
|
for the SW stack |
|
page -532- |