I am in need of some guidance with connecting a 12 button keypad to the Spark Core. To get started, I have been looking at a membrane matrix keypad from AdaFruit which has some example Arduino code (http://proto-pic.co.uk/membrane-matrix-keypad-3x4/) - shown below:
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
This all looks well and good and from what I understand, I would change the rowPins and colPins values to be the actual Spark.IO pins D0, D1, D3, D4 and D5, D6, D7.
With regards to the code shown above, this would obviously need to be pasted somewhere and from the Arduino website, it would suggest that this goes above “void setup()” line (http://playground.arduino.cc/Code/Keypad).
keypad.h would get created as a new file via the Spark.IO Web interface (copying and pasting the code from the actual keypad.h file from the link in the last paragraph). Are any other files required? For example, the ZIP download from the Arduino website includes a utility folder, a file called Keypad.cpp and keywords.txt.
In the setup method, the following goes:
Serial.begin(9600);
and in loop() goes:
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
}
This all seems too easy and before running off to buy keypads and more cores, could anyone confirm whether this will work?