Created
April 11, 2013 19:53
-
-
Save macklinu/5366648 to your computer and use it in GitHub Desktop.
check position of DPST switch
This file contains hidden or 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
| // check position of rocker function | |
| // t = top pin connection to switch | |
| // b = bottom pin connection to switch | |
| int checkRocker(int t, int b) { | |
| int top = digitalRead(t); | |
| int bottom = digitalRead(b); | |
| if (top == LOW && bottom == HIGH) return 0; // top position | |
| else if (top == HIGH && bottom == HIGH) return 1; // middle position | |
| else if (top == HIGH && bottom == LOW) return 2; // low position | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment