HID/examples/Keyboard/NKROKeyboard/NKROKeyboard.ino

59 lines
1.4 KiB
Arduino
Raw Normal View History

2015-09-19 15:58:35 +00:00
/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
NKROKeyboard example
2015-09-20 08:55:13 +00:00
Press a button to hold a lot of keys at the same time.
2015-09-19 15:58:35 +00:00
NKRO can push 113 keys at the same time,
the other Keyboards only 6 keys + 8 modifiers!
2015-10-11 11:58:02 +00:00
You may also use SingleNKROKeyboard to enable a single report NKROKeyboard.
2015-09-19 15:58:35 +00:00
See HID Project documentation for more information.
2015-10-24 08:16:00 +00:00
https://github.com/NicoHood/HID/wiki/Keyboard-API#nkro-keyboard
2015-09-19 15:58:35 +00:00
*/
#include "HID-Project.h"
const int pinLed = LED_BUILTIN;
const int pinButton = 2;
void setup() {
pinMode(pinLed, OUTPUT);
pinMode(pinButton, INPUT_PULLUP);
// Sends a clean report to the host. This is important on any Arduino type.
NKROKeyboard.begin();
}
void loop() {
2015-09-20 08:55:13 +00:00
// Hold a lot of keys at the same time
2015-09-19 15:58:35 +00:00
if (!digitalRead(pinButton)) {
digitalWrite(pinLed, HIGH);
2015-09-20 08:55:13 +00:00
// Do not press to many at once or some OS will have problems.
// Note that the resulting pressed order might differ,
// because all keys are pressed at the same time.
NKROKeyboard.add('0');
NKROKeyboard.add('1');
NKROKeyboard.add('2');
NKROKeyboard.add('3');
NKROKeyboard.add('4');
NKROKeyboard.add('5');
NKROKeyboard.add('6');
NKROKeyboard.add('7');
NKROKeyboard.add('8');
NKROKeyboard.add('9');
NKROKeyboard.send();
2015-09-19 15:58:35 +00:00
// Release all keys and hit enter
NKROKeyboard.releaseAll();
NKROKeyboard.println();
// Simple debounce
delay(300);
}
}