Skip to content

Commit 07278bf

Browse files
authored
Create SimpleKeyboard_HID.ino
Add example code for keyboard from hookup guide
1 parent 5c92c18 commit 07278bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <Keyboard.h>
2+
int buttonPin = 9; // Set a button to any pin
3+
4+
void setup()
5+
{
6+
pinMode(buttonPin, INPUT); // Set the button as an input
7+
digitalWrite(buttonPin, HIGH); // Pull the button high
8+
}
9+
10+
void loop()
11+
{
12+
if (digitalRead(buttonPin) == 0) // if the button goes low
13+
{
14+
Keyboard.write('z'); // send a 'z' to the computer via Keyboard HID
15+
delay(1000); // delay so there aren't a kajillion z's
16+
}
17+
}

0 commit comments

Comments
 (0)