Skip to content

Instantly share code, notes, and snippets.

@wotakuro
Created March 28, 2020 16:01
Show Gist options
  • Save wotakuro/4923bf0cf5d1b820376d2727b2bdca02 to your computer and use it in GitHub Desktop.
Save wotakuro/4923bf0cf5d1b820376d2727b2bdca02 to your computer and use it in GitHub Desktop.
#include "DigiKeyboard.h"
const int LED_PIN = 0;
const int LED_PIN2 = 1;
const int BTN_PIN = 2;
void setup() {
// don't need to set anything up to use DigiKeyboard
pinMode(LED_PIN,OUTPUT);
pinMode(LED_PIN2,OUTPUT);
pinMode(BTN_PIN,INPUT);
DigiKeyboard.sendKeyStroke(0);
}
void loop() {
int val = 0;
val = digitalRead( BTN_PIN);
if( val != HIGH ){
DigiKeyboard.sendKeyStroke(KEY_ENTER);
digitalWrite(LED_PIN , HIGH);
digitalWrite(LED_PIN2 , HIGH);
}else{
digitalWrite(LED_PIN , LOW);
digitalWrite(LED_PIN2 , LOW);
DigiKeyboard.delay(8);
}
DigiKeyboard.delay(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment