It is best if we package up the commands to make the LCD work as a set of functions which we can then re-use.

Note how I have put comments at the top for anyone who wants to change my program to another hardware configuration. I've also arranged things so that the only connection-specific code is in two functions, which I've identified in the comments. This is just good programming practice. If you know something at the time you do it you should write it down. It is amazing how quickly you will forget how you did something!