创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


arduino:libraries:keyboardprint

Description

Sends a keystroke to a connected computer.

Keyboard.print() must be called after initiating Keyboard.begin().

WARNING: When you use the Keyboard.print() command, the Arduino takes over your keyboard! Make sure you have control before you use the command. A pushbutton to toggle the keyboard control state is effective.

Syntax

Keyboard.print(character) Keyboard.print(characters) Parameters

character : a char or int to be sent to the computer as a keystroke characters : a string to be sent to the computer as a keystroke Returns

int : number of bytes sent

Example

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);
  Keyboard.begin();
}
 
void loop() {
  //if the button is pressed
  if(digitalRead(2)==LOW){
    //Send the message
    Keyboard.print("Hello!");
  }
}
本页面的其他翻译:
arduino/libraries/keyboardprint.txt · 最后更改: 2016/12/25 22:15 (外部编辑)