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)

Recommended Answers

All 4 Replies

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()

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.