I wrote my own code as a learning experience.. I have since tried using the Keypad library and I have to say, it is very difficult to work with a keypad when you don't know what's happening in the background. I found that my sketch along with Serial.print functions everywhere is smaller in size than the basic example(below) for the library...(compiles to 3,492 bytes)
#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] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[cols] = {3, 4, 5}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
void setup() {
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
//boolean state = keypad.getState();
if (key != NO_KEY){
Serial.println(key);
}
}
I don't, however, have the ability to use multiple keypads. I suppose I could theoretically add the extra keypads by giving them different names(IO pins might be scarce). I have functions that tell me things like "new_key_pressed()" since getKey (or whatever) may not tell you if a new key was pressed if the same one was pressed. I suppose that "KeypadState getState()" might be used, but I could not figure it out.
My sketch also involves the functionality to generate the button presses(for setting the alarm clock), but when compiled is about half the size:
Binary sketch size: 1742 bytes (of a 30720 byte maximum)
So where does all of the extra usage of memory come from?
pat