PHP Classes
elePHPant
Icontem

File: example/pin.php

Recommend this page to a friend!
  Classes of Andrew Collington  >  iWire PHP Raspberry PI GPIO Class  >  example/pin.php  >  Download  
File: example/pin.php
Role: Example script
Content type: text/plain
Description: Example script
Class: iWire PHP Raspberry PI GPIO Class
Control a Raspberry PI board using GPIO
Author: By
Last change:
Date: 1 year ago
Size: 542 bytes
 

 

Contents

Class file image Download
<?php

/**
 * Phpiwire: A PHP wrapper for wiringPi
 *
 * Checking pin status
 *
 * @author Andrew Collington, andy@amnuts.com
 * @version 0.2.0
 * @link https://github.com/amnuts/phpiwire
 * @license MIT, http://acollington.mit-license.org/
 */

namespace Phpiwire;

$pi = new Board();
$p = $pi->getPin(0)->mode(Pin::OUTPUT);

echo
$p, "\n";

if (
$p->read() == Pin::LOW) {
    echo
"Setting {$p->getId()} to HIGH\n\n";
   
$p->write(Pin::HIGH);
} else {
    echo
"Setting {$p->getId()} to LOW\n\n";
   
$p->write(Pin::LOW);
}

echo
$p, "\n";