One more thing related to hardware. Have you used a variable resistor or a simple resistor between pin3 of lcd and ground ? Connect a preset of value 10k or more instead of a resistor, and try varying the resistance of the preset.
I’m asking so because you’ve shared that the lcd is getting initialized. If the code can initialize an lcd, then there is little chance for an error afterwards.