Arduino serial communication with Python

preview_player
Показать описание
This video shows how to send and receive serial data with an Arduino and Python 2 script

See comments on change needed for Python 3

Рекомендации по теме
Комментарии
Автор

Thanks so much! You really explained it great, best tutorial I could find :)


Just a few Updates for the newest Version of Python you will have to encode and decode the messages for compatibility:
change "x = ser.readline()" to "x =
and change "ser.write("This is my Arduino message\n")" to "ser.write("This is my Arduino message\n".encode())"


Then everything should function perfectly like you showed in the video!

Lamabanana
Автор

Thank you very much, you saved me a lot of time searching for solutions!

mattsparksy
Автор

You should make more thermodynamics video. This was great as well. You should make more of these as well!

AdrianColumbus
Автор

It is a very helpful video. Thank for sharing. It helped me a lot. I am trying to write some code to do a little different. Can you please help me out.
Here is what I am trying do.
1. I have written some code in python using pyautogui and it does some magic. Then after that I want it to send command in Arduino to blink led to indicate that the first job is done.
2. After couple of blinks again python has to run its second part of script and again after completing it has to send command in Arduino to blink led.

(Run first part of Python Script) > (Python Command Arduino to Blink Led) > (After Blinking Led Couple of Times Python will run its second part of Script) > (Again Python command Arduino to Blink Led for couple of times) > (Again Python will run its third part of script) And It will run in a loop.

Thanks in advance
Can you please help me out to find the right way to do this? Please please please.

ashokshrestha
Автор

Traceback (most recent call last):

File "<ipython-input-2-17a7e0cf07a2>", line 4, in <module>
with serial.Serial('COM4', 9600) as ser:

AttributeError: module 'serial' has no attribute 'Serial'
.
.
.
that I faced IDK why any idea?

furkancolak
Автор

Have you ever sent json data from python to Arduino? please help make a video lesson

candrajunus
Автор

When typing in the file name into terminal, I keep getting a “python: can’t open file no such file or directory” instead of the usual error you got purposely. Is using a pi4 the problem?

Koko-cqfb
Автор

unicode strings are not supported, please encode to bytes: what does this mean?

ItsJustSawyer