Go Down

Topic: Serial communication from laptop to arduino using Python3 (Read 389 times) previous topic - next topic


I am running a python program on my laptop doing some image processing and object tracking to keep track of some moving robots in the camera's field of vision.  I need to send data through a serial connection to an arduino which will then communicate to the robots but I am having trouble understanding the protocol.

I am trying to send a command as a string but have not been able to get it working. For example, if I wanted to send a command "turnRight" from my laptop to the arduino, and then send an acknowledgement back to my laptop, what would that look like? 

I am new with serial communication and am sure I am making some novice mistakes but I appreciate any help that I can get!

Here is the test code written for my laptop:

import serial, time

arduino = serial.Serial('COM6', 15200)
command = "turn right"
while True:
   data = arduino.read()
   if data:


This Python - Arduino demo my help.

It will need a little modification for Python 3 as it was written with 2.7

Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up