0

Hi. I want to try and control a Servo motor directly from a USB port. (without using an intermediate microcontroller). To do this, I need to send pulse width modulation signals on one (or more) wires of the USB cable.
Is it possible to do this with python? (I found a library called pyserial but I can't figure out how to use it)

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by mahela007
0

You wont be able to do it with just the usb cable, a microcontroller will be needed to handle all the serial data.

You could use the parallel port to do this, though I haven't done it myself.

import serial

#your COM port will be different 
s = serial.Serial("COM8")

#now it acts like a file handle

s.write("data to be sent\n") #\n is required so the device 
#knows when all data is sent

dataFromDevice = s.readline()

Edited by Tech B: n/a

0

Thanks for the info.. I would like to able to manage without the microcontroller. How could do this using a parallel port?

0

I had already visited the second link. I couldn't really make head or tail of the documentation for pyparallel.

Edited by mahela007: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.