Created
April 12, 2020 12:38
-
-
Save robotjoosen/505a3f32c91e67c0bf71fe3ee3ea6126 to your computer and use it in GitHub Desktop.
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 <Wire.h> | |
#include <Adafruit_ADS1015.h> | |
#include "DigiKeyboard.h" | |
Adafruit_ADS1115 ads; | |
void setup(void) | |
{ | |
Serial.begin(9600); | |
ads.begin(); | |
DigiKeyboard.sendKeyStroke(0); | |
} | |
void loop(void) | |
{ | |
for(int pin = 0; pin < 4; pin++) { | |
int inputValue = ads.readADC_SingleEnded(pin); | |
if(inputValue > 2048) { | |
switch(pin) { | |
case 0 : | |
/** | |
* [x][ ] | |
* [ ][ ] | |
* | |
* Button 1 code here | |
*/ | |
break; | |
case 1 : | |
/** | |
* [ ][ ] | |
* [x][ ] | |
* | |
* Button 2 code here | |
*/ | |
break; | |
case 2 : | |
/** | |
* [ ][x] | |
* [ ][ ] | |
* | |
* Button 3 code here | |
*/ | |
break; | |
case 3 : | |
/** | |
* [ ][ ] | |
* [ ][x] | |
* | |
* Button 4 code here | |
*/ | |
break; | |
} | |
DigiKeyboard.delay(100); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment