Skip to content

Files

Latest commit

Feb 19, 2019
f7666e5 · Feb 19, 2019

History

History
70 lines (47 loc) · 1 KB

keyboardBegin.adoc

File metadata and controls

70 lines (47 loc) · 1 KB
title
Keyboard.begin()

Keyboard.begin()

Description

When used with a Leonardo or Due board, Keyboard.begin() starts emulating a keyboard connected to a computer. To end control, use Keyboard.end().

Syntax

Keyboard.begin()

Parameters

Nothing

Returns

Nothing

Example Code

#include <Keyboard.h>

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!");
  }
}