Skip to content

Instantly share code, notes, and snippets.

@macklinu
Created April 11, 2013 19:53
Show Gist options
  • Select an option

  • Save macklinu/5366648 to your computer and use it in GitHub Desktop.

Select an option

Save macklinu/5366648 to your computer and use it in GitHub Desktop.
check position of DPST switch
// 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