Tutorial.KeyboardReprogram History

Hide minor edits - Show changes to output

August 28, 2015, at 04:13 PM by Simone Maiocchi -
Changed lines 1-6 from:
(:div class=breadcrumb:)
[[Tutorial.HomePage | Tutorials]] > [[Tutorial.Examples | Examples]] > USB > Keyboard >KeyboardReprogram
(:divend:)

(:*toc:)
to:
(:html:)

<div class="subHeader row">

<div class="breadcrumb columns large-10 medium-10">
<p>
<a class="wikilink" href="/en/Tutorial/HomePage">Tutorials </a>
> <a class="wikilink" href="/en/Tutorial/BuiltInExamples"> Built-In Examples </a> > 09.USB > KeyboardReprogram
</p>
</div>
</div>

(:htmlend:)
August 28, 2015, at 04:12 PM by Simone Maiocchi -
Added lines 12-13:

!!!Hardware Required
Deleted line 14:
!!!Hardware Required
Changed lines 19-20 from:
to:
(:divend:)
Changed line 24 from:
(:divend:)
to:
Changed line 26 from:
to:
(:div class=circuit:)
Added lines 36-37:
(:divend:)
Changed lines 51-57 from:
(:include LeonardoSeeAlsoInclude:)
to:
* [[KeyboardLogout]] - Logs out the current user with key commands.
* [[KeyboardMessage]] - Sends a text string when a button is pressed.
* [[KeyboardSerial]] - Reads a byte from the serial port, and sends back a keystroke.
* [[KeyboardAndMouseControl]] - Demonstrates the Mouse and Keyboard commands in one program.
* [[ButtonMouseControl]] - Control cursor movement with 5 pushbuttons.
* [[JoystickMouseControl]] - Controls a computer's cursor movement with a Joystick when a button is pressed.
July 29, 2015, at 04:13 PM by Simone Maiocchi -
Changed lines 8-9 from:
This example uses the Keyboard library to open a new Arduino IDE sketch window, send keyboard commands that type in the Blink example, and reprograms the board. After running this sketch and connecting pin 2 to ground, the board will have a new program, Blink.
to:
This example uses the Keyboard library to open a new Arduino Software (IDE) sketch window, send keyboard commands that type in the Blink example, and reprograms the board. After running this sketch and connecting pin 2 to ground using the pushbutton, the board will have a new program, Blink.
Changed lines 15-16 from:
* hookup wire
to:
* pushbutton
* hook-up wires
* breadboard
Deleted lines 34-35:

(:div class=code :)
Added lines 36-37:

(:div class=code :)
July 29, 2015, at 04:10 PM by Simone Maiocchi -
Deleted line 20:
Changed lines 22-29 from:
Connect your board to your computer with a micro-USB cable.

To run the sketch, connect a hook-up wire from pin 2 to ground. For this to run successfully, keep the Arduino software running as the frontmost application.


[-click the images to enlarge-]

%height=300px%[[Attach: KeyboardSerial_bb.png | Attach: KeyboardSerial_bb.png]]
to:

[-click the image to enlarge-]\\

%height=300px%[[Attach:KeybLogoutFritz.png | Attach:KeybLogoutFritz.png]]
Changed lines 28-31 from:
to:
!!!Schematic

[-click the image to enlarge-]\\
%height=400px%[[ Attach:KeybLogoutScheme.png | Attach:KeybLogoutScheme.png]]
Changed lines 35-36 from:
to:
Connect your board to the USB port, then push the button to connect D2 with GND and initiate the sketch keyboard keypress emulation. Remember to have the Arduino Software (IDE) window selected before you press the button.
Added lines 46-48:
\\
''Last revision 2015/07/29 by SM ''
July 28, 2015, at 10:56 AM by Simone Maiocchi -
Changed lines 18-19 from:
* Arduino IDE
to:
* Arduino IDE running
July 09, 2015, at 12:21 PM by Simone Maiocchi -
Changed lines 1-5 from:
''Examples > Keyboard Library''

!!!Keyboard Reprogram
This example uses the Keyboard library to open a new Arduino sketch window, send keyboard commands that type in the Blink example, and reprograms the board. After running this sketch and connecting pin2 to ground, the Arduinio will have a new program.
to:
(:div class=breadcrumb:)
[[Tutorial.HomePage | Tutorials]] &gt; [[Tutorial.Examples | Examples]] &gt; USB &gt; Keyboard &gt;KeyboardReprogram
(:divend:)

(:*toc:)

!!Keyboard Reprogram
This example uses the Keyboard library to open a new Arduino IDE sketch window, send keyboard commands that type in the Blink example, and reprograms the board. After running this sketch and connecting pin 2 to ground, the board will have a new program, Blink.
Changed line 13 from:
'''Hardware Required'''
to:
!!!Hardware Required
Changed line 17 from:
'''Software Required'''
to:
!!!Software Required
Changed line 22 from:
'''Circuit'''\\
to:
!!!Circuit
Changed lines 34-35 from:
'''Code'''
to:
!!!Code
Changed line 42 from:
'''See Also'''
to:
!!!See Also
October 31, 2012, at 09:53 PM by Scott Fitzgerald -
Changed lines 19-20 from:
Connect your Leonardo board to your computer with a micro-USB cable.
to:
Connect your board to your computer with a micro-USB cable.
October 31, 2012, at 09:53 PM by Scott Fitzgerald -
Changed lines 4-5 from:
This example uses the Keyboard library to open a new Arduino sketch window, send keyboard commands that type in the Blink example, and reprograms the Leonardo or the Due. After running this sketch and connecting pin2 to ground, the Leonardo (or the Due) will have a new program.
to:
This example uses the Keyboard library to open a new Arduino sketch window, send keyboard commands that type in the Blink example, and reprograms the board. After running this sketch and connecting pin2 to ground, the Arduinio will have a new program.
Changed line 10 from:
* Arduino Leonardo or Arduino Due board
to:
* Arduino Leonardo, Micro, or Due board
Changed line 31 from:
to:
Changed lines 33-35 from:
(:source lang=arduino tabwidth=4:)
/*
Arduino Programs Blink
to:

(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino lang=arduino tabwidth=4:)
Deleted lines 35-127:
This sketch demonstrates the Keyboard library.

When you connect pin 2 to ground, it creates a new
window with a key combination (CTRL-N),
then types in the Blink sketch, then auto-formats the text
using another key combination (CTRL-T), then
uploads the sketch to the currently selected Arduino using
a final key combination (CTRL-U).

Circuit:
* Arduino Leonardo or Arduino Due
* wire to connect D2 to ground.

created 5 Mar 2012
modified 29 Mar 2012
by Tom Igoe

This example is in the public domain

http://www.arduino.cc/en/Tutorial/KeyboardReprogram
*/

// use this option for OSX.
// Comment it out if using Windows or Linux:
char ctrlKey = KEY_LEFT_GUI;
// use this option for Windows and Linux.
// leave commented out if using OSX:
// char ctrlKey = KEY_LEFT_CTRL;


void setup() {
// make pin 2 an input and turn on the
// pullup resistor so it goes high unless
// connected to ground:
pinMode(2, INPUT_PULLUP);
// initialize control over the keyboard:
Keyboard.begin();
}

void loop() {
while (digitalRead(2) == HIGH) {
// do nothing until pin 2 goes low
delay(500);
}
delay(1000);
// new document:
Keyboard.press(ctrlKey);
Keyboard.press('n');
delay(100);
Keyboard.releaseAll();
// wait for new window to open:
delay(1000);

// Type out "blink":
Keyboard.println("void setup() {");
Keyboard.println("pinMode(13, OUTPUT);");
Keyboard.println("}");
Keyboard.println();
Keyboard.println("void loop() {");
Keyboard.println("digitalWrite(13, HIGH);");
Keyboard.print("delay(3000);");
// 3000 ms is too long. Delete it:
for (int keystrokes=0; keystrokes < 6; keystrokes++) {
delay(500);
Keyboard.write(KEY_BACKSPACE);
}
// make it 1000 instead:
Keyboard.println("1000);");
Keyboard.println("digitalWrite(13, LOW);");
Keyboard.println("delay(1000);");
Keyboard.println("}");
// tidy up:
Keyboard.press(ctrlKey);
Keyboard.press('t');
delay(100);
Keyboard.releaseAll();
delay(3000);
// upload code:
Keyboard.press(ctrlKey);
Keyboard.press('u');
delay(100);
Keyboard.releaseAll();

// wait for the sweet oblivion of reprogramming:
while(true);
}






(:sourceend:)
October 22, 2012, at 11:23 AM by Federico -
Changed lines 4-5 from:
This example uses the Keyboard library to open a new Arduino sketch window, send keyboard commands that type in the Blink example, and reprograms the Leonardo. After running this sketch and connecting pin2 to ground, the Leonardo will have a new program.
to:
This example uses the Keyboard library to open a new Arduino sketch window, send keyboard commands that type in the Blink example, and reprograms the Leonardo or the Due. After running this sketch and connecting pin2 to ground, the Leonardo (or the Due) will have a new program.
Changed line 10 from:
* Arduino Leonardo board
to:
* Arduino Leonardo or Arduino Due board
Changed line 47 from:
* Arduino Leonardo
to:
* Arduino Leonardo or Arduino Due
May 21, 2012, at 07:52 PM by Scott Fitzgerald -
Changed line 26 from:
%height=300px%[[Attach: KeyboardReprogram_bb.png | Attach: KeyboardReprogram_bb.png]]
to:
%height=300px%[[Attach: KeyboardSerial_bb.png | Attach: KeyboardSerial_bb.png]]
May 21, 2012, at 07:48 PM by Scott Fitzgerald -
Changed lines 33-129 from:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/09.USB(Leonardo)/Keyboard/KeyboardSerial/KeyboardSerial.ino lang=arduino tabwidth=4:)
to:
(:source lang=arduino tabwidth=4:)
/*
Arduino Programs Blink

This sketch demonstrates the Keyboard library.

When you connect pin 2 to ground, it creates a new
window with a key combination (CTRL-N),
then types in the Blink sketch, then auto-formats the text
using another key combination (CTRL-T), then
uploads the sketch to the currently selected Arduino using
a final key combination (CTRL-U).

Circuit:
* Arduino Leonardo
* wire to connect D2 to ground.

created 5 Mar 2012
modified 29 Mar 2012
by Tom Igoe

This example is in the public domain

http://www.arduino.cc/en/Tutorial/KeyboardReprogram
*/

// use this option for OSX.
// Comment it out if using Windows or Linux:
char ctrlKey = KEY_LEFT_GUI;
// use this option for Windows and Linux.
// leave commented out if using OSX:
// char ctrlKey = KEY_LEFT_CTRL;


void setup() {
// make pin 2 an input and turn on the
// pullup resistor so it goes high unless
// connected to ground:
pinMode(2, INPUT_PULLUP);
// initialize control over the keyboard:
Keyboard.begin();
}

void loop() {
while (digitalRead(2) == HIGH) {
// do nothing until pin 2 goes low
delay(500);
}
delay(1000);
// new document:
Keyboard.press(ctrlKey);
Keyboard.press('n');
delay(100);
Keyboard.releaseAll();
// wait for new window to open:
delay(1000);

// Type out "blink":
Keyboard.println("void setup() {");
Keyboard.println("pinMode(13, OUTPUT);");
Keyboard.println("}");
Keyboard.println();
Keyboard.println("void loop() {");
Keyboard.println("digitalWrite(13, HIGH);");
Keyboard.print("delay(3000);");
// 3000 ms is too long. Delete it:
for (int keystrokes=0; keystrokes < 6; keystrokes++) {
delay(500);
Keyboard.write(KEY_BACKSPACE);
}
// make it 1000 instead:
Keyboard.println("1000);");
Keyboard.println("digitalWrite(13, LOW);");
Keyboard.println("delay(1000);");
Keyboard.println("}");
// tidy up:
Keyboard.press(ctrlKey);
Keyboard.press('t');
delay(100);
Keyboard.releaseAll();
delay(3000);
// upload code:
Keyboard.press(ctrlKey);
Keyboard.press('u');
delay(100);
Keyboard.releaseAll();

// wait for the sweet oblivion of reprogramming:
while(true);
}






(:sourceend:)
May 02, 2012, at 04:14 PM by Scott Fitzgerald -
Changed line 33 from:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/09.Keyboard/KeyboardSerial/KeyboardSerial.ino lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/09.USB(Leonardo)/Keyboard/KeyboardSerial/KeyboardSerial.ino lang=arduino tabwidth=4:)
April 27, 2012, at 06:55 PM by Scott Fitzgerald -
Changed lines 6-7 from:
'''NB: When you use the Keyboard.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the Leonardo has received a byte over the serial port.'''
to:
'''NB: When you use the Keyboard.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send Keyboard commands after digital pin 2 is pulled to ground.'''
April 27, 2012, at 06:36 PM by Scott Fitzgerald -
Changed lines 4-7 from:
This example uses the Keyboard library to open a new Arduino sketch window, type in the Blink example, and reprogram the Leonardo.

'''NB: When you use the Keybaord.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the Leonardo has received a byte over the serial port.'''
to:
This example uses the Keyboard library to open a new Arduino sketch window, send keyboard commands that type in the Blink example, and reprograms the Leonardo. After running this sketch and connecting pin2 to ground, the Leonardo will have a new program.

'''NB: When you use the Keyboard.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the Leonardo has received a byte over the serial port.'''
Changed lines 14-15 from:
*none
to:
* Arduino IDE
Changed lines 21-23 from:
To run the sketch, connect a hook-up wire from pin 2 to ground.

to:
To run the sketch, connect a hook-up wire from pin 2 to ground. For this to run successfully, keep the Arduino software running as the frontmost application.

April 27, 2012, at 06:03 PM by Scott Fitzgerald -
Added lines 24-29:
[-click the images to enlarge-]

%height=300px%[[Attach: KeyboardReprogram_bb.png | Attach: KeyboardReprogram_bb.png]]
[-image developed using [[http://www.fritzing.org |Fritzing]]. For more circuit examples, see the [[http://fritzing.org/projects/|Fritzing project page]] -]

Changed line 33 from:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/9.Keyboard/KeyboardSerial/KeyboardSerial.ino lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/09.Keyboard/KeyboardSerial/KeyboardSerial.ino lang=arduino tabwidth=4:)
Changed line 40 from:
\\
to:
(:include LeonardoSeeAlsoInclude:)
April 18, 2012, at 03:34 AM by Scott Fitzgerald -
April 18, 2012, at 12:47 AM by Scott Fitzgerald -
Added lines 1-34:
''Examples > Keyboard Library''

!!!Keyboard Reprogram
This example uses the Keyboard library to open a new Arduino sketch window, type in the Blink example, and reprogram the Leonardo.

'''NB: When you use the Keybaord.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send a Keyboard command after the Leonardo has received a byte over the serial port.'''

(:div class=BOM :)
'''Hardware Required'''
* Arduino Leonardo board
* hookup wire

'''Software Required'''
*none

(:divend:)

'''Circuit'''\\
Connect your Leonardo board to your computer with a micro-USB cable.

To run the sketch, connect a hook-up wire from pin 2 to ground.


'''Code'''

(:div class=code :)
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/9.Keyboard/KeyboardSerial/KeyboardSerial.ino lang=arduino tabwidth=4:)
(:divend:)

'''See Also'''
*[[/Reference/KeyboardWrite | Keyboard.write]]()
*[[/Reference/KeyboardPrint | Keyboard.print]]()
*[[/Reference/KeyboardPrintln | Keyboard.println]]()
\\

Share