16x2 LCD showing garbage values after switching relay

I don't think the problem is in your code, I think it is in your circuit. Please post a schematic.