Skip to content

Instantly share code, notes, and snippets.

@kahagon
Created May 17, 2014 19:35
Show Gist options
  • Select an option

  • Save kahagon/78006800f9e96cbae369 to your computer and use it in GitHub Desktop.

Select an option

Save kahagon/78006800f9e96cbae369 to your computer and use it in GitHub Desktop.
PHP で Arduino を制御する - LED を点灯させよう ref: http://qiita.com/oasynnoum@github/items/91aed309bd9de8af8d0a
{
"name": "phpmake/example-blink-led",
"type": "project",
"require": {
"phpmake/firmata": "dev-master"
}
}
$ composer install
<?php
require dirname(__FILE__) . '/vendor/autoload.php';
/* initialize the device */
$device = new PHPMake\Firmata\Device('/dev/ttyACM0');
/* for Windows */
// $device = new PHPMake\Firmata\Device('COM3');
$pin = 13;
for ($i = 0; $i < 3; ++$i) {
$device->digitalWrite($pin, PHPMake\Firmata::HIGH); // light
sleep(1);
$device->digitalWrite($pin, PHPMake\Firmata::LOW); // unlight
sleep(1);
}
$ php blink-led.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment