I am using the same codes as in the Video on my PC with Windows 10 (64Bits)
Arduino IDE Ver 1.8.13
Python Ver 3.9.0
using IDLE for Python
Iam new to Python using for the First Time with Arduino
Learning the Working of 10DOF from the YouTube Source
and getting the following ERROR
Python Code
the Code is working till Line #11
Please Help to get it working
Arduino IDE Ver 1.8.13
Python Ver 3.9.0
using IDLE for Python
Iam new to Python using for the First Time with Arduino
Learning the Working of 10DOF from the YouTube Source
and getting the following ERROR
Arduino CodeFile "C:/Users/mkbut/AppData/Local/Programs/Python/Python39/Pyas1.py", line 11, in <module>
x=float(splitPacket[0])
ValueError: could not convert string to float: "1 ' 2 ' 4 ' \r\n"
Code:
//Python_9Axis_10DOF
//15.10.20
int x=0;
int y=0;
int z=0;
void setup() {
Serial.begin(115200);
}
void loop() {
x=x+1;
y=y+2;
z=z+4;
Serial.print(x);
Serial.print(" ' ");
Serial.print(y);
Serial.print(" ' ");
Serial.print(z);
Serial.println(" ' ");
delay(100);
}
Code:
import serial
import time
arduinoData=serial.Serial('com7',115200)
time.sleep(1)
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[3])
print("X=",x,"Y=",y,"Z=",z)
the Code is working till Line #11
after that the ERROR is comingPython 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
==== RESTART: C:/Users/mkbut/AppData/Local/Programs/Python/Python39/Pyas1.py ===
["1 ' 2 ' 4 ' \r\n"]
["2 ' 4 ' 8 ' \r\n"]
["3 ' 6 ' 12 ' \r\n"]
["4 ' 8 ' 16 ' \r\n"]
["5 ' 10 ' 20 ' \r\n"]
["6 ' 12 ' 24 ' \r\n"]
["7 ' 14 ' 28 ' \r\n"]
["8 ' 16 ' 32 ' \r\n"]
["9 ' 18 ' 36 ' \r\n"]
...
...
...
...
...
...
["412 ' 824 ' 1648 ' \r\n"]
["413 ' 826 ' 1652 ' \r\n"]
["414 ' 828 ' 1656 ' \r\n"]
["415 ' 830 ' 1660 ' \r\n"]
["416 ' 832 ' 1664 ' \r\n"]
["417 ' 834 ' 1668 ' \r\n"]
Please Help to get it working