Very little needs to be changed. Assuming that it has the same 16 pins, in the setup type lcd.begin(8, 2); instead of lcd.begin(16, 2);. Same applies for larger lcds as well (just change the numbers in the parenthesis to the size of lcd being used) if they have the same 16 pins.