Loading...

Tutorial.KeyboardMessage History

Show minor edits - Show changes to markup

October 31, 2012, at 04:54 PM by Scott Fitzgerald -
Changed lines 21-24 from:

Attach one end of the pushbutton to pin 4 on the Leonardo. Attach the other end it +5V. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

Once you've programmed your Leonardo, unplug the USB cable and open a text editor. Connect your Leonardo board to your computer and press the button to write in the document.

to:

Attach one end of the pushbutton to pin 4 on the Arduino. Attach the other end to power. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

Once you've programmed your board, unplug the USB cable and open a text editor. Connect the board to your computer and press the button to write in the document.

October 31, 2012, at 04:47 PM by Scott Fitzgerald -
Changed line 11 from:
  • Arduino Leonardo or Arduino Due board
to:
  • Arduino Leonardo, Micro, or Due board
Changed line 36 from:
 (:div class=code :)
to:

(:div class=code :)

Changed line 38 from:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.USB/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

October 31, 2012, at 04:44 PM by Scott Fitzgerald -
Added lines 36-38:
 (:div class=code :)

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.USB/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

Deleted lines 39-89:

(:div class=code :) (:source lang=arduino tabwidth=4:) /*

 Keyboard Button test

 Sends a text string when a button is pressed.

 The circuit:
 * pushbutton attached from pin 2 to +5V on AVR boards
   and to +3.3V to the Arduino Due
 * 10-kilohm resistor attached from pin 2 to ground

 created 24 Oct 2011
 modified 27 Mar 2012
 by Tom Igoe

 This example code is in the public domain.

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

const int buttonPin = 2; // input pin for pushbutton int previousButtonState = HIGH; // for checking the state of a pushButton int counter = 0; // button push counter

void setup() {

  // make the pushButton pin an input:
  pinMode(buttonPin, INPUT);
  // initialize control over the keyboard:
  Keyboard.begin();

}

void loop() {

  // read the pushbutton:
  int buttonState = digitalRead(buttonPin);
  // if the button state has changed, 
  if ((buttonState != previousButtonState) 
    // and it's currently pressed:
  && (buttonState == HIGH)) {
    // increment the button counter
    counter++;
    // type out a message
    Keyboard.print("You pressed the button ");
    Keyboard.print(counter); 
    Keyboard.println(" times.");
  }
  // save the current button state for comparison next time:
  previousButtonState = buttonState; 

}

(:sourceend:)

October 22, 2012, at 05:18 AM by Federico -
Changed lines 4-6 from:

When the button is pressed in this example, a text string is sent to the computer as keyboard input. The string reports the number of times the button has been pressed. Once you have the Leonardo programmed and wired up, open up your favorite text editor to see the results.

to:

When the button is pressed in this example, a text string is sent to the computer as keyboard input. The string reports the number of times the button has been pressed. Once you have the Leonardo programmed and wired up, open up your favourite text editor to see the results.

Changed line 11 from:
  • Arduino Leonardo board
to:
  • Arduino Leonardo or Arduino Due board
Changed lines 45-46 from:
 * pushbutton attached from pin 2 to +5V
 * 10-kilohm resistor attached from pin 4 to ground
to:
 * pushbutton attached from pin 2 to +5V on AVR boards
   and to +3.3V to the Arduino Due
 * 10-kilohm resistor attached from pin 2 to ground
Changed line 58 from:

const int buttonPin = 4; // input pin for pushbutton

to:

const int buttonPin = 2; // input pin for pushbutton

October 19, 2012, at 05:57 AM by Federico -
Changed line 57 from:

const int buttonPin = 2; // input pin for pushbutton

to:

const int buttonPin = 4; // input pin for pushbutton

May 21, 2012, at 01:43 PM by Scott Fitzgerald -
Changed lines 38-86 from:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.USB(Leonardo)/Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source lang=arduino tabwidth=4:) /*

 Keyboard Button test

 Sends a text string when a button is pressed.

 The circuit:
 * pushbutton attached from pin 2 to +5V
 * 10-kilohm resistor attached from pin 4 to ground

 created 24 Oct 2011
 modified 27 Mar 2012
 by Tom Igoe

 This example code is in the public domain.

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

const int buttonPin = 2; // input pin for pushbutton int previousButtonState = HIGH; // for checking the state of a pushButton int counter = 0; // button push counter

void setup() {

  // make the pushButton pin an input:
  pinMode(buttonPin, INPUT);
  // initialize control over the keyboard:
  Keyboard.begin();

}

void loop() {

  // read the pushbutton:
  int buttonState = digitalRead(buttonPin);
  // if the button state has changed, 
  if ((buttonState != previousButtonState) 
    // and it's currently pressed:
  && (buttonState == HIGH)) {
    // increment the button counter
    counter++;
    // type out a message
    Keyboard.print("You pressed the button ");
    Keyboard.print(counter); 
    Keyboard.println(" times.");
  }
  // save the current button state for comparison next time:
  previousButtonState = buttonState; 

}

(:sourceend:)

May 02, 2012, at 10:13 AM by Scott Fitzgerald -
Changed line 38 from:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.USB(Leonardo)/Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

April 27, 2012, at 12:54 PM by Scott Fitzgerald -
Changed lines 7-8 from:

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 includes a pushbutton to toggle the keyboard, so that it only runs after a button is depressed.

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 includes a pushbutton to toggle the keyboard, so that it only runs after the button is pressed.

April 27, 2012, at 11:44 AM by Scott Fitzgerald -
Changed line 28 from:
to:
Changed line 38 from:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/9.Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/09.Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

Added line 45:

(:include LeonardoSeeAlsoInclude:)

March 28, 2012, at 01:21 PM by Scott Fitzgerald -
Deleted line 38:

(:sourceend:)

Deleted line 44:

\\

March 28, 2012, at 01:21 PM by Scott Fitzgerald -
Changed line 20 from:

Circuit

to:

Circuit\\

Added line 39:

(:sourceend:)

March 28, 2012, at 01:20 PM by Scott Fitzgerald -
Added lines 21-25:

Attach one end of the pushbutton to pin 4 on the Leonardo. Attach the other end it +5V. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

Once you've programmed your Leonardo, unplug the USB cable and open a text editor. Connect your Leonardo board to your computer and press the button to write in the document.

click the images to enlarge

Changed lines 27-32 from:
 Attach one end of the pushbutton to pin 4 on the Leonardo. Attach the other end it +5V. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

Once you've programmed your Leonardo, unplug the USB cable and open a text editor. Connect your Leonardo board to your computer and press the button to write in the document.

click the images to enlarge

to:
March 28, 2012, at 01:19 PM by Scott Fitzgerald -
Changed lines 22-23 from:

Connect your Leonardo board to your computer with a micro-USB cable. Attach one end of the pushbutton to pin 4 on the Leonardo. Attach the other end it +5V. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

to:
 Attach one end of the pushbutton to pin 4 on the Leonardo. Attach the other end it +5V. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

Once you've programmed your Leonardo, unplug the USB cable and open a text editor. Connect your Leonardo board to your computer and press the button to write in the document.

Changed line 45 from:

\\

to:

\\

December 06, 2011, at 07:44 PM by Scott Fitzgerald -
Changed lines 39-42 from:
to:
December 06, 2011, at 07:18 PM by Scott Fitzgerald -
Changed lines 7-8 from:

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.move(). This sketch includes a pushbutton to toggle the keyboard, so that it only runs after a button is depressed.

to:

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 includes a pushbutton to toggle the keyboard, so that it only runs after a button is depressed.

December 06, 2011, at 07:16 PM by Scott Fitzgerald -
Added lines 6-8:

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.move(). This sketch includes a pushbutton to toggle the keyboard, so that it only runs after a button is depressed.

November 28, 2011, at 03:08 PM by Scott Fitzgerald -
Changed line 33 from:

(:source http://github.com/arduino/Arduino/raw/master/libraries/Keyboard/examples/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/9.Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

November 27, 2011, at 11:12 AM by Scott Fitzgerald -
Changed line 33 from:

(:source http://github.com/arduino/Arduino/raw/master/libraries/Keyboard/Examples/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/libraries/Keyboard/examples/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

November 27, 2011, at 11:11 AM by Scott Fitzgerald -
Changed line 33 from:

(:source http://github.com/arduino/Arduino/raw/master/libraries/Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/libraries/Keyboard/Examples/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:)

November 21, 2011, at 06:49 PM by Scott Fitzgerald -
Added line 18:

(:div class=circuit:)

Changed lines 21-29 from:
to:

click the images to enlarge

Attach:KeyboardMessage_bb.png Δ Δ image developed using Fritzing. For more circuit examples, see the Fritzing project page

(:divend:)

November 19, 2011, at 12:37 PM by Scott Fitzgerald -
Added lines 1-28:

Examples > Keyboard Library

Keyboard Message

When the button is pressed in this example, a text string is sent to the computer as keyboard input. The string reports the number of times the button has been pressed. Once you have the Leonardo programmed and wired up, open up your favorite text editor to see the results.

(:div class=BOM :) Hardware Required

  • Arduino Leonardo board
  • One momentary pushbutton
  • One 10-kiloohm resistor

Software Required

  • Any text editor

(:divend:)

Circuit Connect your Leonardo board to your computer with a micro-USB cable. Attach one end of the pushbutton to pin 4 on the Leonardo. Attach the other end it +5V. Use the resistor as a pull-down, providing a reference to ground, by attaching it from pin 4 to ground.

Code

(:div class=code :) (:source http://github.com/arduino/Arduino/raw/master/libraries/Keyboard/KeyboardMessage/KeyboardMessage.ino lang=arduino tabwidth=4:) (:divend:)

\\




Bookmark and Share