LCD pin connection

hi

is there any specific order of connecting the lcd pins to the arduino ?
can I connect any digital pin to the lcd or should some be PWM pins?

There is no need for PWM to be connected to an LCD unless it has an adjustable backlight. For RS, EN, D0-7 need digital pins (non-PWM).

In summary.

On the UNO or equivalent (ATmega328), all I/O pins are digital pins, some can be used in alternate fashion such as PWM or analog inputs if necessary.

You do not need PWM to drive an LCD but you could use PWM to control the brightness of the backlight - though this is not a very useful function at all (except perhaps two alternate “day” and “night” settings as well as off). To either control its brightness or simply switch it on or off, you need a transistor (or FET) as a buffer between the Arduino pin and the backlight as the backlight draws more current than the Arduino pin can safely supply.

The contrast voltage - pin 3 - is not to be confused with the backlight brightness, once set, the contrast virtually never requires further adjustment.

Also, it is generally a waste of ports on the Arduino to use 8-bit data; virtually all control libraries expect to drive it in four-bit data mode using D4 to D7; D0 to D3 on the LCD do not need to be connected. The libraries generally permit you to specify which pins you choose to connect to which lines on the LCD.

is there any specific order of connecting the lcd pins to the arduino ?

Any available I/O pin on your Arduino can be used for any of the LCD signals. Just make sure that the pin numbers that you use are listed, in the correct order, in the the LiquidCrystal lcd(...); statement.

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

Don