"Serial.print" special keys?

I've written a simple script where I press a button, which in turn Serial.prints a keystroke. My next step is to use that to activate a keyboard shortcut...a combination of two keys pressed simultaneously.

So I'm wondering two things:

  1. Is it possible to Serial.print something that's not a character, like Ctrl, Shift, or Command?

  2. If so, can you Serial.print two keys at the same time, perhaps with a delay(1000) after Serial.printing the first key?

Or would you guys suggest a better way to go about this?

send the ascii code

We did this in the "days of DOS". Take the interpreted key code character. There is a DOS service call that returns the scan code for non-printable keys...
if thats any help to get you started.

What you're looking for is to turn your arduino into a USB keyboard. You can do it with an uno, but it's much easier with an arduino leonardo (google it in either case)

Hm, well then a follow-up: how would I get it to "press" a special key, like F6? On a friend's advice, I tried Serial.print("key_f6");, but looking at the serial monitor, I think it's just printing key_f6 as a string.

What WizenedEE said (did you see his message?)

With Uno you would need v-usb or equivalent. Leonardo or Teensy --> very easy.

With Uno you would need v-usb or equivalent.

Looks like I'm s.o.l. with my UNO then. As far as I can tell, I'd need to download a DFU Programmer first. I can't do that without installing MacPorts, and I can't install MacPorts without Xcode, and I can't install Xcode 4 (the only one Mac makes available now) on Mac 10.6.

Grr.

Any other thoughts? All I want to do is have Arduino send a signal to launch a script that plays a particular song (in iTunes, Quicktime, whatever application I can). I was thinking I could do it with a button: press the button, which signals a keyboard shortcut, which launches a script to play the song. So it looks like that approach is out, at least with my UNO/O.S. combination.

Is there a whole different angle I could take?

I'm not so sure that you're SOL, but I'm getting out of my zone here-- I have used Teensy for things like that, it's dirt simple and it has usb dongle-like format...

akwhitacre:

With Uno you would need v-usb or equivalent.

Any other thoughts? All I want to do is have Arduino send a signal to launch a script that plays a particular song (in iTunes, Quicktime, whatever application I can). I was thinking I could do it with a button: press the button, which signals a keyboard shortcut, which launches a script to play the song. So it looks like that approach is out, at least with my UNO/O.S. combination.

Is there a whole different angle I could take?

Are you simply doing this as an intellectual exercise or just because you're bored ? Seems like an awful lot of work just to play a music download. I would just buy an old laptop and get a illegal COUGH ! real copy of Windoze or whatever and use that.

F6 is ASCII 246 decimal, 11110110 binary. Try writing that.

Are you simply doing this as an intellectual exercise or just because you're bored ? Seems like an awful lot of work just to play a music download. I would just buy an old laptop and get a illegal COUGH ! real copy of Windoze or whatever and use that.

lol. Isn't everything an intellectual exercise? :slight_smile: I'm doing a silly project to learn about pairing a sensor and a computer, beyond the basic serial monitoring. I have a waterproof thermometer, and when it senses a pot of water has reached 100 deg. Celsius (that the water is boiling) I want it to tell the UNO to tell the computer to play an .mp3 clip of a James Brown yell.

GoForSmoke:
F6 is ASCII 246 decimal, 11110110 binary. Try writing that.

http://www.ascii-code.com/

That's still basically a character, as opposed to the function key F6. Someone might have mentioned it up-thread or I saw it somewhere else today, but I've learned you can't print function keys, Crtl, Shift, etc. in the programming sense. At least not without turning my Arduino into a USB keyboard, per WizenedEE's reply and stuff I've read elsewhere.

So you tried and it didn't work. Because we all know that all PC programs work the same...

GoForSmoke:
So you tried and it didn't work. Because we all know that all PC programs work the same...

Sorry?

GoForSmoke:
F6 is ASCII 246 decimal, 11110110 binary. Try writing that.

http://www.ascii-code.com/

The serial monitor reads from the serial port and displays the character on a java TextBox. You can't generate a system-event, such as the one pressing F6 does, by displaying a character on a textbox.

akwhitacre:

Are you simply doing this as an intellectual exercise or just because you're bored ? Seems like an awful lot of work just to play a music download. I would just buy an old laptop and get a illegal COUGH ! real copy of Windoze or whatever and use that.

lol. Isn't everything an intellectual exercise? :slight_smile: I'm doing a silly project to learn about pairing a sensor and a computer, beyond the basic serial monitoring. I have a waterproof thermometer, and when it senses a pot of water has reached 100 deg. Celsius (that the water is boiling) I want it to tell the UNO to tell the computer to play an .mp3 clip of a James Brown yell.

Ahh ! I get it. I take back what I said, that's a useful project. Slow blues with James yelling "Yaa coffeeee is readdyyyyy...... Mann!" and then a pumping Sax after that.
Yeahhhh. Thats a great proj.

Note too, that he is on a Mac, it probably has different function key mapping.

It might be easier to write an AppleScript that reads the serial port and performs the action you need.