I have a very basic setup with a potentiometer hooked up to my Arduino analog 0 pin with it spamming output to the serial monitor. I am attempting to get the output in blender to match the arduino output by using the following code:
from time import sleep as wait
import serial
ser = serial.Serial("COM4",9600)
while 1==1:
wait(1)
print(ser.readline())
This code freezes the main window and also outputs whatever the initial value for the potentiometer was despite rotating it so the output gets stuck outputting something like
b'493\r\n'
b'493\r\n'
b'493\r\n'
I realise that these issues are mainly due to the fact that my loop is endless but I'm not really sure how to create a coroutine in python and all the tutorials I've tried either don't work or require extra modules. I'd also like to know why it is outputting differently from the arduino serial monitor and how I can solve that.
This is the arduino code/output
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(0));
}
574
576
578