You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've been testing arduino communication with serial.
during running it always connected , buy sometime the read is incorrect
python in run in version 3.9 in Debian 11
constintbuttonPin=4;
intbuttonState=0;
intvalue=0;
voidsetup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLUP);
}
voidloop() {
buttonState=digitalRead(4);
if (buttonState==HIGH)
{
value=0x01;
} elseif (buttonState==LOW)
{
value=0x00;
}
if (Serial.available()) {
// Sending value to pythonSerial.println(value);
}
delay(500);
}
It is very simple code, basically the arduino will send a value 0x01 when button is press and 0x00 when not every .5 second
When starting the python script, sometime the delay is lower then .5 second, and any button press in the arduino will not send the correct value , it kept sending the default value.
On re-connection either by repluging the usb cable or restarting the script might cause the same problem. The most visible is when I clear the terminal.
Testing same script in windows 10 with port COM3 ( using pyserial ) the problem doesn't seem to occur
Any idea what the cause ?
The text was updated successfully, but these errors were encountered:
Hi, I've been testing arduino communication with serial.
during running it always connected , buy sometime the read is incorrect
python in run in version 3.9 in Debian 11
This is the python code
This is arduino part
It is very simple code, basically the arduino will send a value 0x01 when button is press and 0x00 when not every .5 second
When starting the python script, sometime the delay is lower then .5 second, and any button press in the arduino will not send the correct value , it kept sending the default value.
On re-connection either by repluging the usb cable or restarting the script might cause the same problem. The most visible is when I clear the terminal.
Testing same script in windows 10 with port COM3 ( using pyserial ) the problem doesn't seem to occur
Any idea what the cause ?
The text was updated successfully, but these errors were encountered: