Skip to content

Instantly share code, notes, and snippets.

@zach-c-d
Created August 17, 2017 18:07
Show Gist options
  • Save zach-c-d/9221c83d85446dbf0b9cf90c44a7a320 to your computer and use it in GitHub Desktop.
Save zach-c-d/9221c83d85446dbf0b9cf90c44a7a320 to your computer and use it in GitHub Desktop.
checks all sensors for input and lights corresponding LED
int centerPad = A0;
int rightPad = A1;
int bottomPad = A3;
int leftPad = A5;
int centerLED = 2;
int rightLED = 3;
int bottomLED = 4;
int leftLED = 7;
int sensors[] = { centerPad, rightPad, bottomPad, leftPad };
int LEDs[] = { centerLED, rightLED, bottomLED, leftLED };
int turnOn[] = {};
int hitThreshold = 700;
for (int i = 0; i < sensors.length; i ++){
checkPad(sensors[i], LEDs[i]);
}
int checkPad(int pad, int LED){
if(analogRead(pad) > hitThreshold){
turnOn.Append(LED);
}
}
void getInput(){
checkPad(centerPad, centerLED);
checkPad(rightPad, rightLED);
checkPad(bottomPad, bottomLED);
checkPad(leftPad, leftLED);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment