Jan-29-2025, 06:52 PM
(This post was last modified: Jan-29-2025, 08:43 PM by deanhystad.)
Hi
I am having trouble with getting this code to work. I am working on a project where I want to transfer data from Arduino through a com terminal and having Python grabbing it. The problem is that the serial module does not seem to work. I have installed serial using "pip install serial" and it said that it installed sucessfully, but I am not so sure. Lastly, I do not have anything plugged into the com port or Arduino IDE running. To me this should not matter, but I am a noob :/
By the way, I am watching a youtube video by Paul McWorther, Using an Arduino with Pyhton LESSON 3: Passing Data From Arduino to Pyhton
This is the code so far:
I am having trouble with getting this code to work. I am working on a project where I want to transfer data from Arduino through a com terminal and having Python grabbing it. The problem is that the serial module does not seem to work. I have installed serial using "pip install serial" and it said that it installed sucessfully, but I am not so sure. Lastly, I do not have anything plugged into the com port or Arduino IDE running. To me this should not matter, but I am a noob :/
By the way, I am watching a youtube video by Paul McWorther, Using an Arduino with Pyhton LESSON 3: Passing Data From Arduino to Pyhton
This is the code so far:
import vpython import time import serial arduinoData = serial.Serial('COM6',9600) time.sleep(1) while True: while(arduinoData.inWaiting()==0): pass dataPacket = arduinoData.readline() print(dataPacket)This is the console message I get back:
Error:Users/user/Programmering/vPython')
Traceback (most recent call last):
File C:\ProgramData\Anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\user\programmering\vpython\vpython_test.py:13
arduinoData = serial.Serial('COM6',9600)
AttributeError: module 'serial' has no attribute 'Serial'
deanhystad write Jan-29-2025, 08:43 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.