PHP code example of marabesi / arduino-php-wrapper
1. Go to this page and download the library: Download marabesi/arduino-php-wrapper 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/ */
marabesi / arduino-php-wrapper example snippets
composer
php
\Arduino\Wrapper::register();
//reads data from Arduino
$resource = fopen('arduino://ttyUSB0', 'r+');
print fread($resource, 1024);
php
print file_get_contents('arduino://ttyUSB0');
php
\Arduino\Wrapper::register();
//writes data to Arduino
$resource = fopen('arduino://ttyUSB0', 'r+');
print fwrite('hello Arduino');