I'm working on a RPI controlled quadcopter. The PWM is generated by ServoBlaster. I've written a Python script to control the motors' speed. Assume that I'm using GPIO4 to control the motor. If I want to set the pulse wifth to 1000us I have to write this
echo 0=1000us > /dev/servoblaster to the terminal (where 0 is the reference to the GPIO4). How can I run this command (writing 0=1000us to /dev/servoblaster) from a Python script in an effective way. The "effective" is important, because I've been using
subprocess.call(["echo 0=1000us > /dev/servoblaster"], shell=True) , but this uses much CPU time.
I've also tried:
python myScript > /dev/servoblaster, where myScript is:
but it does nothing.
EDIT: I've tried this way:
dev = open('/dev/servoblaster', 'w') dev.write('0=1000us\n')
but the servo does not moves.