PHP code example of microscrap / scrapyard-usb

1. Go to this page and download the library: Download microscrap/scrapyard-usb 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/ */

    

microscrap / scrapyard-usb example snippets


use GeneralPurposeIO\Contracts\SPI\SPIMode;

$panel = app('gpio.spi')->driver('usb')->connectTo('ft232h')->mode(SPIMode::MODE_0)->speed(10_000_000)->register()->device('ft232h', 0);
$dc = app('gpio.digital')->driver('usb')->output('ft232h', 1);

$sensor = app('gpio.i2c')->driver('usb')->connectTo('ft232h')->register()->device('ft232h', 0x76);
$id = $sensor->writeRead([0xD0], 1);

$radio = app('gpio.uart')->driver('usb')->connectTo('ft232h')->baud(115_200)->register()->device('ft232h');
$radio->write("AT+VER?\r\n");
$reply = $radio->readUntil("\r\n", timeout_ms: 1000);