Last active
October 31, 2018 21:47
-
-
Save robokingsk/265b9cdb87de1955cdf8bbe8465ea994 to your computer and use it in GitHub Desktop.
Emulacia klavesnice a vypisanie spravy 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)) { | |
Keyboard.println("Stlacil si tlacidlo"); | |
} | |
BTN_previous_state = BTN_state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment