Created
August 17, 2017 18:07
-
-
Save zach-c-d/9221c83d85446dbf0b9cf90c44a7a320 to your computer and use it in GitHub Desktop.
checks all sensors for input and lights corresponding LED
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
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