I have IO pin scarcity. Thinking of sharing IO ports PC0 to PC3 between JHD162A based LCD display data lines and Keypad in Atmega328P-AU. Attached is the schematic (Only outline and not full schematic). I tested using simple code and it worked. But in the long run, will there be any design issues?
Attached is the source code. Debounce is done is crude way and need to update and my only worry is debounce that might create problem.
PC0 to PC3 are output by default so that LCD display can be used any time.
Whenever keypad need to be canned, these PC0 to PC3 are made input lines (in getKeyStatus function) and key pad is scanned. After keypad scanning, PC0 to PC3 are made outputs again at the end of getKeyStatus().