php-gpio icon indicating copy to clipboard operation
php-gpio copied to clipboard

run servomotor using this library

Open H889761123 opened this issue 9 years ago • 1 comments

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?

H889761123 avatar Apr 11 '15 15:04 H889761123

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.

calcinai avatar Sep 30 '16 11:09 calcinai