binding key

Hello,

First I'm a noob in programming. I have a Teensy ++ 2.0 and I need to bind a serial input to the F11 key. I tried in many different ways also the examples, but I can't seem to make it work.
Can anyone help me with this simple question?

and I need to bind a serial input to the F11 key.

What does this mean? The F11 key is something that the Teensy can OUTPUT.

dlaine:
Hello,

First I'm a noob in programming. I have a Teensy ++ 2.0 and I need to bind a serial input to the F11 key. I tried in many different ways also the examples, but I can't seem to make it work.
Can anyone help me with this simple question?

You want a serial comms program that binds keys to output strings?
Which OS?

Ok, sorry I will try to make it more clear.
I have a mechanical camera head that normally is connected through a small USB cable to a digital camera ( in my case a Canon).
The head gives a signal to the camera whenever the shutter has to close, in other words when the camera should take a picture.
What i do now is I have an other technical IR camera that is controlled with a computer programme of it's own. The camera is conected to my laptop (windows 7) with a USB cable and I can take a picture through the camera programme using the F11 key.
What I want to do is use that camera on the mechanical head. I connect my Teensy to the head with a USB cable on pin 10, then I connect the usb port on my Teensy to my computer. Now whenever the head gives a signal to close the shutter I want my computer to give the F11 command to the camera programme. Is that possible?
I hope this is clear enough?
This is the latest code I'm trying without any succes.

void setup() {

  Serial.begin(9600);

  pinMode(10, INPUT_PULLUP);

  delay(4000);

}

void loop() {

  if (digitalRead(10) == HIGH) {

    delay(10);

  } else {

    Keyboard.print("KEY_F11"); //

    delay(1000);

  }

This is the latest code I'm trying without any succes.

"Without any succes(s)" is just about as lame as "it doesn't work". The code you posted does something. You haven't said what it does.

You expect it to do something. You haven't said what.

Sending F11 to the PC is NOT the same as some application on the PC understanding F11 and doing something when the F11 is pressed. Is the application that is supposed to deal with the F11 key actually active?

Yes, the application is active that understands the F11 key.
The programme takes a snapshot whenever the F11 key is pressed.
The code I used does nothing with the F11 key in the programme.

dlaine:
Yes, the application is active that understands the F11 key.
The programme takes a snapshot whenever the F11 key is pressed.
The code I used does nothing with the F11 key in the programme.

Then, it's time to add some Serial.print() statements, to confirm that the Keyboard.print() statement is being executed. I don't believe, though, that KEY_F11 is a string. I believe that there is a #define statement that assigns the name KEY_F11 a value, and it is that value that you should be sending.

Can you clarify what kind of serial .print() statements I should add?
About the string, isn't there a string on next page? C code for Teensy: USB Keyboard
And what is the #define statement for the F11 key?

About the string, isn't there a string on next page?

No. Not a string in sight.

Have you even tried compiling the code with:

    Keyboard.print(KEY_F11); // a useless ass comment

instead of

    Keyboard.print("KEY_F11");

Maybe even upload and test the code.

Keyboard.print(KEY_F11) does not work.
When I open Word and press test shutter on my mechanical head, it prints "16452" on the screen.

When I open Word and press test shutter on my mechanical head, it prints "16452" on the screen.

What gets printed if you press the F11 key?

Why are you expecting Word to do something with the F11 key?

Shouldn't you have Keyboard.begin() somewhere ???

...R

I solved it. The code I used and that works is

void setup() {

  Serial.begin(9600);

  pinMode(10, INPUT_PULLUP);

  delay(4000);

}

void loop() {

  if (digitalRead(10) == HIGH) {

    delay(10);

  } else {

Keyboard.set_key1(KEY_F11);
Keyboard.send_now();
Keyboard.set_key1(0);
Keyboard.send_now();


    delay(1000);

  }

dlaine:
I solved it.

Like PaulS suggested, in other words.

Interesting ....

The API for that Keyboard library is different from the one for the Leonardo.

...R