Teensy and Arduino Leonardo code share

void setup() {
// You don't need to initialize anything for
// this simple code.
}

// loop() function will loop all
// the time doing the same thing over, and over again!
void loop()
{

// delaying at the beginning is good till the OS
// detects the hardware.
delay(5500);

/* open run command in windows */
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI); // WIN key
Keyboard.set_key1(KEY_R); // "R" key
Keyboard.send_now(); // send everything
delay(3500); // delay till the "run command" opens
// sometimes it takes time!

/* clear the modifier and key1 */
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now(); // send everything
delay(2500); // I love delays =p

/* write notepad.exe and press enter
to open notepad */
Keyboard.print("notepad.exe");
Keyboard.set_key1(KEY_ENTER); // Enter key
Keyboard.send_now(); // send everything

/* clear key1 */
Keyboard.set_key1(0);
Keyboard.send_now(); // send everything

delay(2500); // I told you i love delays

/* Write something and press enter */
Keyboard.print("Hello there....?");
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
Keyboard.send_now();
delay(2500);
Keyboard.print("Well, I'm a small device that programmed by Qnix");
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
Keyboard.send_now();
delay(2500);
Keyboard.print("I do nothing in the mean time, but he will make me do things...");
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
Keyboard.send_now();
delay(2500);

// delay( FOR EVER );
// at the end you can delay for ever or find a way to stop it! =)
}

this code in arduino IDE and select teensy 2.0 Can compile.

but i select arduino leonardo cann't compile.

i need this code to arduino leonardo how to do?

I tried to add #include, but appeared a lot of error.

Chinese English, hope everybody can help me. :slight_smile:

I tried to add #include, but appeared a lot of error.

You tried to include what? What errors appeared?

Teensy devices can be programmed using the Arduino IDE, but libraries developed specifically for the Teensy can be expected to operate with other Arduino products.

sketch_nov07a.cpp:19: ??? ‘class Keyboard_’????‘set_modifier’???
sketch_nov07a.cpp:19: ??? ‘MODIFIERKEY_RIGHT_GUI’??????????
sketch_nov07a.cpp:20: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:20: ??? ‘KEY_R’??????????
sketch_nov07a.cpp:21: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:26: ??? ‘class Keyboard_’????‘set_modifier’???
sketch_nov07a.cpp:27: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:28: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:34: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:34: ??? ‘KEY_ENTER’??????????
sketch_nov07a.cpp:35: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:38: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:39: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:45: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:46: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:47: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:48: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:51: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:52: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:53: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:54: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:57: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:58: ??? ‘class Keyboard_’????‘send_now’???
sketch_nov07a.cpp:59: ??? ‘class Keyboard_’????‘set_key1’???
sketch_nov07a.cpp:60: ??? ‘class Keyboard_’????‘send_now’???