Created
December 29, 2016 18:52
-
-
Save MichMich/89c3e399df02855a001840e993982e4c to your computer and use it in GitHub Desktop.
QuizButtons
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
#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