One of the example projects uses the INKEY command to read a PS/2 keyboard.
I cannot seem to find this command in any of the help files.
Can someone shed a little more light on how to implement this command?
Thanks,
Dan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First, you need to add two lines at the start of the program to specify what pins the keyboard is connected to. For example,
#define PS2Clock PORTB.1
#define PS2Data PORTB.2
Then, you use the INKEY function to read the ASCII code of the currently pressed key. To store the value of the pressed key in a variable called UserInput, you'd use this line:
UserInput = INKEY
If no key is pressed, then INKEY will be equal to 0.
Not all keys are currently detected - the PS/2 routines are still a work in progress. However the letter, number/symbol, Enter, Backspace, Space and Esc keys should all work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Curiously is there any method in GCBasic that would do the exact opposite of this function? Allowing a PIC device to emulate a PC Keyboard?
I'm currently looking at implimenting keyboard emulation by writing up a subroutine in gcbasic, but if there's an existing facility i'd rather work with that :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, there isn't currently anything in GCBASIC to simulate a PS/2 keyboard. If you do write some code to simulate a keyboard, I'd love to include it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One of the example projects uses the INKEY command to read a PS/2 keyboard.
I cannot seem to find this command in any of the help files.
Can someone shed a little more light on how to implement this command?
Thanks,
Dan
First, you need to add two lines at the start of the program to specify what pins the keyboard is connected to. For example,
#define PS2Clock PORTB.1
#define PS2Data PORTB.2
Then, you use the INKEY function to read the ASCII code of the currently pressed key. To store the value of the pressed key in a variable called UserInput, you'd use this line:
UserInput = INKEY
If no key is pressed, then INKEY will be equal to 0.
Not all keys are currently detected - the PS/2 routines are still a work in progress. However the letter, number/symbol, Enter, Backspace, Space and Esc keys should all work.
Curiously is there any method in GCBasic that would do the exact opposite of this function? Allowing a PIC device to emulate a PC Keyboard?
I'm currently looking at implimenting keyboard emulation by writing up a subroutine in gcbasic, but if there's an existing facility i'd rather work with that :)
Sorry, there isn't currently anything in GCBASIC to simulate a PS/2 keyboard. If you do write some code to simulate a keyboard, I'd love to include it.
Great.. Thanks!