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