1. Go to this page and download the library: Download chickentikkamasala/gpio library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public function index(GPIOManager $manager)
{
$manager->create('greenled', 2);
$manager->greenled = 'ON';
}
public function index(GPIOManager $manager)
{
//create an analog sensor
$manager->create('sensor', 3, 'aread');
$value = $manager->sensor;
return response()->json(['sensor' => $value]);
}
use ChickenTikkaMasala\GPIO\GPIO;
class RedLED extends GPIO
{
public function __construct()
{
parent::__construct(1, 'pwm', 'OFF');
}
public function getMethod()
{
return 'out';
}
}
public function index(GPIOManager $manager)
{
$redLED = new RedLED();
$manager->add($redLED);
}
//PWM all the below = 1023
$manager->redled = 'HIGH';
$manager->redled = 'UP';
$manager->redled = 'ON';
//Where as for write and awrite: these equal to 1
$manager->redled = 'HIGH';
$manager->redled = 'UP';
$manager->redled = 'ON';
//all equal to 1
//The below all equal to 0
$manager->redled = 'LOW';
$manager->redled = 'DOWN'
$manager->redled = 'OFF';
$redled = $manager->get('redled');
//if you wanted to put it back simply use the add function again
$manager->add('redled', $redled);
$redled = $manager->get('redled');
$redled->increment(1023, 200);
//redled will 'fade' from 0 to 1023
//increment will increase every 200th millisecond
$redled->decrement(0, 200);
$manager->add('redled', $redled);