Skip to content

Instantly share code, notes, and snippets.

@HerrSpace
Created March 22, 2014 18:40
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 HerrSpace/9712142 to your computer and use it in GitHub Desktop.
Save HerrSpace/9712142 to your computer and use it in GitHub Desktop.
const int x[] = { 1,2,3,4 };
const int y[] = { 5,6,7,8 };
int buttonPressed[2] = {-1,-1};
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("test!");
for (int idx_x = 0; idx_x < 4; idx_x++) {
pinMode(idx_x, INPUT);
}
for (int idx_y = 0; idx_y < 4; idx_y++) {
pinMode(idx_y, INPUT_PULLUP);
}
}
void loop() {
for (int idx_x = 0; idx_x < 4; idx_x++) {
pinMode(idx_x, OUTPUT);
for (int idx_y = 0; idx_y < 4; idx_y++) {
if(digitalRead(idx_y) == LOW) {
buttonPressed[0] = idx_x;
buttonPressed[1] = idx_y;
}
}
pinMode(idx_x, INPUT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment