Skip to content

Instantly share code, notes, and snippets.

@Crysknife007
Created July 16, 2021 16:34
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 Crysknife007/69b2b13719187ee6784f3eafa5ca131a to your computer and use it in GitHub Desktop.
Save Crysknife007/69b2b13719187ee6784f3eafa5ca131a to your computer and use it in GitHub Desktop.
Digispark Press Space Bar with Arcade Button
#include "DigiKeyboard.h"
// Define button pin
const int buttonPin = 2;
// Define button state
int buttonState = 0;
// Setup
void setup() {
// Set button to input
pinMode(buttonPin, INPUT_PULLUP);
}
// Main loop
void loop() {
// Read the button state
buttonState = digitalRead(buttonPin);
// If the button state is low
if ( buttonState == LOW ) {
// Send a spacebar key press
DigiKeyboard.sendKeyPress(44);
}
// Else clear the keys
else {
// Clear all the keys
DigiKeyboard.sendKeyStroke(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment