
KEYS is a pseudo variable which can be used to read the state of various digital input lines. KEYS is read-only. Any attempt to write KEYS will be rejected by the compiler. Each bit of KEYS belongs to one input line. Currently, these bits are defined:
BIT 0 Port P1.17 on the LPC2366. This pin is used for the external key. This signal is inverted by the firmware: Pulling the key pin to ground causes the KEYS command to issue a one.
BIT 1 The CTS input of the RS232 interface which is P2.2 on the LPC2366, if RS232 flow control is not set to RTS/CTS. Otherwise this bit is always 0.
BIT 2 The DSR input of the RS232 interface which is P2.4 on the LPC2366.
BIT 3 The DCD input of the RS232 interface which is P2.3 on the LPC2366
New since version 3.48: The following inputs can also be read with the KEYS pseudo variable. But this only works if that pin is configured as input. Please see the PORT command: click
BIT4 Pin 2 on the base module
BIT5 Pin 3 on the base module
BIT6 Pin 4 on the base module
BIT7 Pin 5 on the base module
BIT8 Pin 6 on the base module
BIT9 Pin 7 on the base module
BIT10 Pin 8 on the base module
BIT11 Pin 9 on the base module
BIT12 Pin 10 on the base module
BIT13 Pin 11 on the base module
BIT14 Pin 12 on the base module
BIT15 Pin 15 on the base module
BIT16 Pin 16 on the base module
This program reads the external key in an endless loop and shows if it is pressed:
outmode -2
do
if KEYS and 1 then
print "pressed"
while KEYS and 1
wend
end if
loop
To extract single bits, you can use the AND operator.