20 lines
429 B
Arduino
20 lines
429 B
Arduino
|
#include <Keyboard.h>
|
||
|
int buttonPin = 9; // Set a button to any pin
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
pinMode(buttonPin, INPUT_PULLUP); // Set the button as an input
|
||
|
Keyboard.begin();
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
if (digitalRead(buttonPin) == 0) // if the button goes low
|
||
|
{
|
||
|
Keyboard.press('z'); // send a 'z' to the computer via Keyboard HID // delay so there aren't a kajillion z's
|
||
|
}else{
|
||
|
Keyboard.releaseAll();
|
||
|
}
|
||
|
delay(50);
|
||
|
}
|