Cursor Keys

Hi Everyone

I am trying to program the Ardino to recognise the cursor keys on my powerbook(simply to pull in a relay when the key is pressed and release it when the key is released .). Do they return ASCII codes as I can't find any in the table or perhaps I haven't looked hard enough?. Have trawled through most all of the forum pages but to no avail. Yes I know i could use a joystick or switches but that means carrying more hardware around. It would be so cool to just plug the device into the USB and just use it .

Yours Stumped for now Jon

Hey,

I donno what the characters they are on the MAC, but in windows the escape, control, alt, cursor keys etc. are all special characters not in the ASCII table. I know in the Delphi programming language, these "virtual keys" have names like VK_Shift, VK_Cursor, VK_Left and so on, but I not sure what they are in your programming language.

-Z-

hi

the easy way to test this is to write some code to recognize keyboard presses through the serial monitor in the Arduino IDE. Anyway, the standard ASCII table is here.

The up/down keys are what are called "non-printing" keys. This might be wrong, but I think the ascii values are 28,29,30 and 31, or $1C, $1D, $1E and $1F.

Why not just use another key? Failing that, you can easily remap your keyboard, making the up/down send but that might mess things up for other applications. If I recall correctly, MAX and PD also have the ability to recognize apple-specific keys.

D

Hi all again
yes using other keys is another way of looking at it , using the cursor keys was perhaps just too obvious. The relays just control( control signals only) a pan tilt head with a big camera on just need one 100 ft cable to control things instead of 2 or 3.

Thanks again
may post again in mac forum

Jon

what a quick response can sleep on the problem now

Ah I'm being confusing. I shouldn't have said "not in the ASCII table", and VK_Cursor is not even a key! They are all in the keyboard table, but the table I think may be different on different OSes.

Here are the the key codes for windows:

http://api.farmanager.com/en/winapi/virtualkeycodes.html

Maybe the keyboard table is the same for macs, I'm not sure.

-Z-

You’re sending keystrokes from a terminal application, and the actual characters sent depend on what sort of terminal that’s being emulated. The most common is the VT100, which IIRC send a sequence something like [A for a cursor key. Yep, a little experiment with xterm and od -c indicates the VT100 sequences are [A [B [C [D for up, down, left, right respectively. An easy way to code for this would be to ignore ESC and [ characters and act on A B C D. This assumes, of course, that your terminal app emulates a VT100.

I have no idea how the arduino IDE behaves; I don’t have an easy way of testing it at hand (i.e., I’d have to get out of my chair :slight_smile: ).

-j

Thanks again everyone for pointing me in the right direction. Can I assume the mac emulates VT 100 or is that just for PCs.

Jon

Fed up with blinking LEDs

Can I assume the mac emulates VT 100 or is that just for PCs.

That's a function of your terminal application, not the OS, but it so happens that both Mac's Terminal.app and X11 xterm emulate VT100 by default.

-j

Here's a resource on how to use OSX's terminal as a serial terminal: http://www.tigoe.net/pcomp/resources/archives/avr/000749.shtml

Note though: what you're trying to do is send a serial command via a key on your laptop. Using Terminal will mean you'll have to type commands in to be sent to Arduino, which involves more steps than merely pressing up or down on your cursorpad.

You should be able to make an applescript that will send serial commands. You can then find a third party app for binding keyboard keys to applescripts (versiontracker.com turned up several when I searched last night). This is probably your best bet.

Thank you so much for pointing me in the right direction. Have some scripts from sailing clicker and have managed to play around with my mobile 990 and got that to work .Now I'm getting into this.

Thanks all