php-gpio
php-gpio copied to clipboard
run servomotor using this library
Hi I am trying to simulate PWM by writing this code to run a servomotor
#!/usr/bin/env php
<?php
require 'vendor/autoload.php';
use PhpGpio\Gpio;
$gpio = new GPIO();
$gpio->output(18,0);
while(true)
{
$gpio->output(18,1);
usleep(1500);
$gpio->output(18,0);
usleep(2000000);
}
but the servo is not working, a similar code is written in python on this video and it is working: http://www.youtube.com/watch?v=ddlDgUymbxc&feature=youtu.be
any ideas?
I suspect you'll find that sysfs
isn't fast enough to toggle the pin state that quickly. You're probably better off using the hardware PWM.