Last active
October 31, 2018 21:47
-
-
Save robokingsk/670e5afb23cd92e9bd503f1627285797 to your computer and use it in GitHub Desktop.
Emulacia klavesnice a stlacenia klavesovej skratky cez Arduino Leonardo/Arduino pro Micro
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
//includnutie kniznice ktora sluzi na emulaciu klavesnice | |
#include <Keyboard.h> | |
int BTN_previous_state = HIGH; // pomocna premenna ktora sluzi na zistenie ci sme tlacidlo pustili | |
void setup() { | |
// nastav pin 9 ako vstup s vnutornym pullupom | |
pinMode(9, INPUT_PULLUP); | |
//inicializujeme emulaciu klavesnice | |
Keyboard.begin(); | |
} | |
void loop() { | |
// nacitaj digitalnu hodnotu pinu 9 | |
int BTN_state = digitalRead(9); | |
// Ak tlačidlo stlačene a pustene | |
if ((BTN_state != BTN_previous_state)&&(BTN_state == HIGH)) { | |
//Stlacenie laveho CTRL tlacidla | |
Keyboard.press(KEY_LEFT_CTRL); | |
//Stlacenie V tlacidla | |
Keyboard.press('v'); | |
//pustime stlacene tlacidla | |
Keyboard.releaseAll(); | |
} | |
BTN_previous_state = BTN_state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment