-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also enables the option for further raw HID development.
- Loading branch information
Showing
9 changed files
with
251 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright (c) 2014-2015 NicoHood | ||
See the readme for credit to other people. | ||
KeyboardLed example | ||
Press a button to toogle caps lock. | ||
Caps lock state is represented by the onboard led. | ||
See HID Project documentation for more information. | ||
https://github.com/NicoHood/HID/wiki/Keyboard-API | ||
*/ | ||
|
||
#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. | ||
Keyboard.begin(); | ||
} | ||
|
||
|
||
void loop() { | ||
// Update Led equal to the caps lock state. | ||
// Keep in mind that on a 16u2 and Arduino Micro HIGH and LOW for TX/RX Leds are inverted. | ||
if (Keyboard.getLeds()&LED_CAPS_LOCK) | ||
digitalWrite(pinLed, HIGH); | ||
else | ||
digitalWrite(pinLed, LOW); | ||
|
||
// Trigger caps lock manually via button | ||
if (!digitalRead(pinButton)) { | ||
Keyboard.write(KEY_CAPS_LOCK); | ||
|
||
// Simple debounce | ||
delay(300); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.