# AVR sleep interrupt with keypad

I'd like to wake up my AVR whenever any button on the keypad is pressed. I am using Keypad.h library and simple 4x4 keypad made of buttons connected straight to AVR digital pins. Keypad itself works perfect.

One question is: Why are there pull-ups connected to rows/cols in some schemes? When it works without them...

For waking AVR up I found that simple attaching 4-input AND to kepyad columns would solve the problem. Before sleep, AVR should set all columns to OUTPUT (HIGH) and then attach interrupt on INPUT INT1 (pin 1) when LOW. So AND inputs are all HIGH till any button is pressed, then it sets LOW on AND output, so INT1 is triggered. But then I saw Keypad.h library source:

 void Keypad::scanKeys() {
// Re-intialize the row pins. Allows sharing these pins with other hardware.
for (byte r=0; r<sizeKpd.rows; r++) {
pin_mode(rowPins[r],INPUT_PULLUP);
}

// bitMap stores ALL the keys that are being pressed.
for (byte c=0; c<sizeKpd.columns; c++) {
pin_mode(columnPins[c],OUTPUT);
pin_write(columnPins[c], LOW);  // Begin column pulse output.
for (byte r=0; r<sizeKpd.rows; r++) {
bitWrite(bitMap[r], c, !pin_read(rowPins[r]));  // keypress is active low so invert to high.
}
// Set pin to high impedance input. Effectively ends column pulse.
pin_write(columnPins[c],HIGH);
pin_mode(columnPins[c],INPUT);
}}


I don't get why are columns set as INPUTS at the end? Could this be skipped? If so, I'll change it to OUTPUT and connect all columns to 74HCT21 inputs and attach output to INT1 pin.

Are there any additional parts needed to connect the 74HCT21? Or it can be connected straight to the 3.3 V regulated power source like this?

Thank you very much!