diff --git a/examples/bitmap.php b/examples/bitmap.php index 3945f71..3dcd504 100644 --- a/examples/bitmap.php +++ b/examples/bitmap.php @@ -20,5 +20,9 @@ for($n = 0; $n < 7; $n++) { $par->setGpioPin($n,$gpio[$n]); } -$par->write(0xFF); -$par->write(0x00); +for($n = 0; $n < 10; $n++) { + $par->write(0xFF); + usleep(500000); + $par->write(0x00); + usleep(500000); +} diff --git a/lib/GpioPin.php b/lib/GpioPin.php index f5d2664..ea97252 100644 --- a/lib/GpioPin.php +++ b/lib/GpioPin.php @@ -76,7 +76,9 @@ class GpioPin public function __destruct() { - fclose($this->fd); + if ($this->fd) { + fclose($this->fd); + } } public function setDirection($direction)