Created
March 22, 2014 18:40
-
-
Save RonjaPonja/9712142 to your computer and use it in GitHub Desktop.
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
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