Skip to content

Instantly share code, notes, and snippets.

@robotjoosen
Created April 12, 2020 12:38
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 robotjoosen/505a3f32c91e67c0bf71fe3ee3ea6126 to your computer and use it in GitHub Desktop.
Save robotjoosen/505a3f32c91e67c0bf71fe3ee3ea6126 to your computer and use it in GitHub Desktop.
#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