diff --git a/libraries/USBHID/examples/Keyboard/Keyboard.ino b/libraries/USBHID/examples/Keyboard/Keyboard.ino index 6b00d5083..715940dcd 100644 --- a/libraries/USBHID/examples/Keyboard/Keyboard.ino +++ b/libraries/USBHID/examples/Keyboard/Keyboard.ino @@ -1,15 +1,26 @@ +/************************************************************** +** Brief introduction to a few HID Keyboard commands. ** +** Unlike the other Keyboard library, this one doesn't use ** +** the "press", "release", and "send" commands. ** +**************************************************************/ + #include "PluggableUSBHID.h" #include "USBKeyboard.h" USBKeyboard Keyboard; -void setup() { - // put your setup code here, to run once: +// Arbitrary pin. +const int CONTROL_PIN = 2; +void setup() { + // We will use this to start/end the prints. + pinMode(CONTROL_PIN, INPUT_PULLUP); } void loop() { - // put your main code here, to run repeatedly: - delay(1000); - Keyboard.printf("Hello world\n\r"); + // This will run only if the control pin is connected to ground. + if( digitalRead(CONTROL_PIN) == LOW){ + delay(1000); + Keyboard.printf("Hello world\n\r"); + } }