Skip to content

Instantly share code, notes, and snippets.

@MichMich
Created December 29, 2016 18:52
Show Gist options
  • Save MichMich/89c3e399df02855a001840e993982e4c to your computer and use it in GitHub Desktop.
Save MichMich/89c3e399df02855a001840e993982e4c to your computer and use it in GitHub Desktop.
QuizButtons
#include <Arduino.h>
#include <Keyboard.h>
#define BUTTON_A 3
#define BUTTON_B 4
#define BUTTON_C 5
#define BUTTON_D 6
void setup() {
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);
pinMode(BUTTON_D, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
bool buttonA = !digitalRead(BUTTON_A);
bool buttonB = !digitalRead(BUTTON_B);
bool buttonC = !digitalRead(BUTTON_C);
bool buttonD = !digitalRead(BUTTON_D);
if (buttonA || buttonB || buttonC || buttonD) {
if (buttonA) Keyboard.write('A');
if (buttonB) Keyboard.write('B');
if (buttonC) Keyboard.write('C');
if (buttonD) Keyboard.write('D');
delay(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment