Hi all! I'm pretty new to all of this, and am trying to get Python set up on MacOS Catalina 10.15.5. The end goal here is to create some 3D modeling in Visual Python. I'm able to get the Arduino to pass data to Python, but when python starts spitting it out, there's a time lag. Its kind of hard to explain without a video, but it prints one line across from left to right, then the next line, and so on. If I run the same Arduino program on the Arduino serial monitor, it moves in real time, spitting out each line in its entirety, then the next line, and so on. Forgive me if I'm using the wrong terms. This is all very new to me. I've copied my Arduino code and Python code below. This is just a sample program I wrote to make sure everything works properly.
// Arduino Code //
int x=0;
int y=0;
int z=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //passes data to Python over COM port
}
void loop() {
// put your main code here, to run repeatedly:
x=x+1;
y=y+2;
z=z+4;
Serial.print(x);
Serial.print(",");
Serial.print(y);
Serial.print(",");
Serial.println(z); //println on last line of data to push to Python
}
#Python Code
import serial
import time
arduinoData=serial.Serial('/dev/cu.usbserial-AB0JQXT9', 115200)
time.sleep(0)
while (1==1):
while (arduinoData.inWaiting()==0):
pass
dataPacket=arduinoData.readline()
dataPacket=str(dataPacket, 'utf-8')
splitPacket=dataPacket.split(",")
X=float(splitPacket[0])
Y=float(splitPacket[1])
Z=float(splitPacket[2])
print('X=',X,', Y=',Y,', Z=',Z)