Outputting Keyboard commands

higgeh

New Member
Im thinking about trying to get my picaxe to output keyboard commands. i.e. if i press a button it will output a key to a ps2 port

any ideas people
 

higgeh

New Member
thanks ecclectic just so everyone knows this is no uni project just a bit of fun

im trying to make a game controller app for picaxe chips.

i.e. you can control games using customised controllers made from picaxe chips

so this is how i think it may work (trial run coming to a compiler near you)

take a key input from a switch (i.e. input 1,2,3,4,5,6)
recognise which key input it is (if statement)
then use the bit from the manual as below to send a signal to a PS2 Connector

serout 1,N2400,(“Hello”)- Sends a message to the screen.
serout 1,N2400,(10) - Sends a direct ASCII instruction to the screen.
serout 1,N2400,(b1) - Sends an ASCII character stored in variable to the screen.
serout 1,N2400,(#b1) - Sends a number stored in a variable to the screen.
serin 0,N2400,b1 - Receives an ASCII character from a keypress on the
keyboard and stores it as the ASCII value in a variable (b1)
serin 0,N2400,#b1 - Receives a real number from the number keys on the
keyboard and stores it in a variable (b1)

please can someone tell me if im on the right lines. Ill write the code up later on tonight and put it on to a 40x tomorrow
 

hippy

Technical Support
Staff member
It's more complicated to send into a PC's PS/2 port than using SEROUT/SERIN, but I'm not really sure what we're doing here - is PS2, a PC keyboard port, a PlayStation or what ? Have we now moved on to communicating via a PC serial port ?

Even if SEROUT and SERIN did work, there's more to it to get stuff received onto the screen and data back from the PC.
 

higgeh

New Member
ok i should explain a bit more

im making a pc input device (i know i can buy them or mod something else but i want to use the chip to do other things)

what i would like to do is this

Press a button on a customised controller (simple push to make switch)

This would be connected to a picaxe 40x chip

when the 40x recognises the button has been pressed it would send the data (through an IBM compatible PS/2 Connector) to a computer

there the computer would recognise it as a keystroke i.e. "A"

my view was if picaxe can receive keyboard data using serin why cant it spit the same data out on serout?
 

BeanieBots

Moderator
my view was if picaxe can receive keyboard data using serin why cant it spit the same data out on serout?
A PICAXE CAN'T receive keyboard data using serin.
It can receive SERIAL (RS232) data using serin.
It can receive keyboard data using keyin.
To the best of my knowledge, there is no "keyout" command.

However, if you know the keyboard comms protocol, I would expect it would be possible to bit-bang the data out in a way that emulates a keyboard.
 

papaof2

Senior Member
"my view was if picaxe can receive keyboard data using serin why cant it spit the same data out on serout?"

Keyboard data is passed using the PS2 keyboard protocol, which is NOT RS232 serial.

Reading a PC keyboard requires using a chip that supports the keyboard protocol. The A and X series chips can read a PC keyboard via the KEYIN command. The X1 and X2 chips can read a keyboard via the KBIN command. None of the other chips (8, 8M, 14, 20) support reading the PC keyboard. See manual 2 for KBIN and KEYIN references.

None of the PICAXE chips provide a native PS2 output. You might be able to simulate the protocol by bit-banging.

John
 

hippy

Technical Support
Staff member
There has been discussion of using a PICAXE as if it were itself a keyboard in the past but I don't know if anyone ever got it to work.

A potentially easier option is to have the PICAXE communicate with the PC via its serial port and run an application on the PC ( which can live in the System Tray ). That can take incoming serial and fake it to Windows such that it looks like the data came from the keyboard. That simplifies the PICAXE side of things but adds more complication on the PC itself. There may be some PC Applications which can do this already or you may have to write your own.
 

Mycroft2152

Senior Member
A PICAXE CAN'T receive keyboard data using serin.
It can receive SERIAL (RS232) data using serin.
It can receive keyboard data using keyin.
To the best of my knowledge, there is no "keyout" command.

However, if you know the keyboard comms protocol, I would expect it would be possible to bit-bang the data out in a way that emulates a keyboard.
Here's a link:

http://www.computer-engineering.org/ps2protocol/

But Hippy's suggestion of a keyborad wedge program isthe easiest method.

Do a forum search on "wedge", you'll find this has been discussed before.

Myc

Note:

There are thousands of responses in the forum archives. There is a good chance that your problem has been discussed previoulsy. Do yourself a favor and start with a forum search. There is a TAB at the top of the page.
 
Last edited:

MPep

Senior Member
The other way would be to purchase a cheap keyboard, take out the internal processor and, say you require the letter S, find out the wiring required and close the contact somehow.

For the contact use a 4016 or 4066.

Just a suggestion.
 
Last edited:
Top