Skip to content

Instantly share code, notes, and snippets.

@robokingsk
Last active October 31, 2018 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robokingsk/265b9cdb87de1955cdf8bbe8465ea994 to your computer and use it in GitHub Desktop.
Save robokingsk/265b9cdb87de1955cdf8bbe8465ea994 to your computer and use it in GitHub Desktop.
Emulacia klavesnice a vypisanie spravy cez Arduino Leonardo/Arduino pro Micro
//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