keypad sleep

Good afternoon,

I’m learning to use sleep modes in arduino, but I have a problem I can not solve.
I have arduino, lcd shift register, and keypad.

Click on various number and when I click on the arduino 3 goes into sleep.
The problem is when I wake the Arduino it deletes the message from the screen, but the keypad does not work. I click on the numbers but does not appear on any screen.

I wonder what I’m doing wrong?

#include <ShiftLCD.h>
#include <Keypad.h>
#include <avr/power.h>
#include <avr/sleep.h>
int wakePin = 2;

ShiftLCD lcd(19, 17, 18);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{‘D’,’#’,‘0’,’*’},
{‘C’,‘9’,‘8’,‘7’},
{‘B’,‘6’,‘5’,‘4’},
{‘A’,‘3’,‘2’,‘1’},
};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {12, 11, 10, 9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
lcd.begin(16, 2);
//setup the pushbutoon
pinMode(wakePin, INPUT);
digitalWrite(wakePin, HIGH);

attachInterrupt(0, wakeUpNow, LOW);
}
void loop()
{
char key = keypad.getKey();

if (key!= NO_KEY){
lcd.print(key);
if (key == ‘3’ ){
sleepNow();
}
}
}

void wakeUpNow()
{
lcd.clear();

}

void sleepNow()
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_cpu ();
attachInterrupt(0,wakeUpNow, LOW);
sleep_mode();
sleep_disable();
detachInterrupt(0);

}

The keypad library works by polling the pins so if the microcontroller is asleep then the keypad is asleep. You'll need to wire up some diodes and connect the pins to an external interrupt. CrossRoads added a hardware interrupt to his keypad and if you scroll down two more posts you'll see his code to go with it.

Good night
I managed to solve all my problems.
However I have seen here in the forum that it is possible for the keypad to wake the Arduino.
http://www.crossroadsfencing.com/Diode_AND_interrupt.jpg
Assembled according to the image with the 1N4007 diodes, but when I click on the keypad to arduino wake up, do not wake up.
If you use the button to have the part works.

thank a lot that can help me in this matter.

The code is attached.

sleep_key_func.ino (2.51 KB)