My version is the program shown on the right. It simply monitors the state of PORTA bit 0 and prints an appropriate message. It does this so quickly that the message appears to change instantaneously when the button is pressed. I use the & operator to split of the bottom bit of PORTA for the testing.

I hope you didn't forget the set up the ports correctly. The call of lcd_setup will set up those ports needed by the LCD but I have added my own setup function to set up TRISA for PORTA.

Note how I have added spaces onto the end of the "up" message so that the "wn" part of the down message is erased each time the display is updated. Note also I am not clearing the display between redraws. If you do this the screen will flicker horribly.

Run project called Exercise 8.1. Press LA0 and note how the message changes.