LCD used for debugging breaks functionality when removed, no idea why

Hey guys, I'd really appreciate anyone's input on this.

I have a camera plugged into a computer, using python for facial detection and tracking communicating through serial and everything works just fine, but when I remove a call to print to the coords of the face to the LCD the tracking stops (servos are still working, tested without any LCD mention and they work, and I can see coords are being sent from python as expected!) Its super strange imo. Here's the code:

#include <Servo.h>
#include <LiquidCrystal.h>
Servo servoVer; //Vertical Servo
Servo servoHor; //Horizontal Servo
int servoYValue = 0;
int x;
int y;
int prevX;
int prevY;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup()
{ 
  lcd.begin(16, 2); 
  Serial.begin(115200);
  Serial.setTimeout(1);
  servoVer.attach(5); //Attach Vertical Servo to Pin 5
  servoHor.attach(6); //Attach Horizontal Servo to Pin 6
  servoVer.write(servoYValue);
  servoHor.write(90); //This is currently confgiured for a continuous rotation servo.
}

and


void loop()
{
  if(Serial.available() > 0)
  { 
    if(Serial.read() == 'X')
    {
     lcd.print(x);
      x = Serial.parseInt();
      Serial.read();  //Lol moves forward two spaces in the data received from python, because its passed as a rounded decimal so we must skip the . and 0 (gets rounded, so is always .0)
      Serial.read();      
      if(Serial.read() == 'Y')
      {
       y = Serial.parseInt();
       Pos();
      }
    }
    while(Serial.available() > 0)
    {
      Serial.read();
    }
  }
}

Commenting out the import, lcd instantiation, and subsequent lcd object usage makes the it no longer track faces. Coords are still being sent from python by that code properly. I've tested motors with this config and tried replacing the lcd.print(x) call with print of x to the console instead, same results however.

Thanks so much for reading <3

Tell us the whole story

Not sure what else info you're looking for, but it's a face tracking camera using the widely available code across different Arduino project websites. I used an LCD to debug values since I cant use the console while having a continuous usage of the serial port, now when removing the calls that simply print to the LCD it stops functioning as it was before. Here's a link to the repo if that helps https://github.com/LanaDelSlay/Arduino-Face-Tracking

That's quite a hard sentence to understand.

And there's another

Whoops first one was an error, here's a clarification for the second: I commented out the import (the include) commented out the instantiation (LiquidCrystal lcd(7, 8, 9, 10, 11, 12);), and commented out the usage of lcd entirely. After, it stopped tracking faces, seemingly not calling the Pos() function anymore.

When I print the data type using the Arduino LCD Library does it alter the data at all? This is the only reason I could guess why it affecting the functionality at all.

I fixed this indirectly by making python send the data as an int instead of a float, and now it works regardless of if the print statement is there. Check the github link if you wanna see exactly what I did. :smile: