Weird LCD Screen Issues

Hello all,
Having an issue with a 16x2 LCD screen where it only works when I attach a servo motor to pin 30 and in no other way (I know it sounds weird). So the code I have copied below works, but if I comment out the part where I attach the servo motor or change which pin it is attach to it prints weird characters or nothing at all on the LCD. So I'm guessing it isn't the wiring as I can get a successful output and I have checked the continuity of the wires. I have also tried using the super basic lcd scripts and they have the same issue. I am wiring it up with a Uno where previously I had a Mega. I have also used pin 6 to vary the contrast instead of using hardware.

Any help would be appreciated, thanks.

#include <Servo.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

Servo Femur1;
void setup() {
  Femur1.attach(30);
  lcd.begin(16, 2);
  pinMode(6, OUTPUT);
}


void loop() {
    analogWrite(6, 110);
    lcd.print("hello world");
    delay(10000);
    
  }

You need to post your code between tags so it can be read !

Have fixed, sorry.

Please show post a copy of the “super basic” lcd code that doesn’t work and a decent photograph of your wiring so we can see the big picture. As it is, you’re doing goofy stuff by attaching servos to non-existent pins and then asking us to make guesses as to the source of the problem. That’s not a formula for problem solving.

Troubleshooting is a process that begins with the absolute minimum configuration in both hardware and software and working towards a functioning system. Asking why adding a servo attach command makes it work is irrelevant and it obscures the actual problem.

I would expect the issue is either simple mis-wire or a lack of components and/or a lack of understanding of how the contrast is actually controlled on on 1602 and similar lcd’s.

Ok, the reason why I am including the fact that the servo should be attached is because I had a full program written out for a walking routine that had the LCD working but not other program would, so I deleted all the other code that I could without affecting the LCD and narrowed it down to that pin attachment. It was working with all other code previously.
I have also soldered the LCD screen to a perf board, so I could combine all the positive and grounding pins into one jumper cable, and sorry for the bad photo but its hard to get a good angle of the soldering.
Here is also the basic code I tested it with:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}

void loop() {
}

Those Chinese jumper wires are absolute crap and probably didn’t survive the soldering. Between the soldering and the wires, the problem is most likely baked into those two aspects of the the interconnects.

Have you verified resistance with an ohmmeter of each connection from the lcd side of the display to the pins of the Uno? You’ll likely find one or more connection open.

You’ll find the standard square pin “DuPont” jumpers to be far more reliable and easier to work with. With the .025 inch square pin headers, it is easier to solder just the single header pins and use female to female jumpers.

And yes, your soldering needs some more practice. Not bad but not consistent enough to be reliable.

Yeah it was one of my first goes at properly using a perf board so the soldering was a bit rough, and thanks for the advice on the jumper cables. I tested it again though today without changing anything and it worked properly so not sure what the problem was. I'll probably remake it though with better cables.

Thanks for all the help.

Before you solder next time, get some flux and liberally spread it around. The tin will flow so much better, and it will contact your pads well.
You can even use plumbers flux, such as the Laco brand.

Steve

steve1001:
You can even use plumbers flux...

:o :o :o :o :o :o :o

NEVER EVER use plumbers flux for electronics.
The high acid content will corrode things very fast.

Only beginners could do with a bit of flux (for electronics),
but it usually makes a mess if you don't clean it up afterwards.
Experienced tinkerers with the right tools don't need flux.
Leo..

I will stand by what I said.
I clean up afterwards with Isopropyl.
I have homemade boards that are 20 year old, and are still good.

Steve