Created
May 17, 2014 19:35
-
-
Save kahagon/78006800f9e96cbae369 to your computer and use it in GitHub Desktop.
PHP で Arduino を制御する - LED を点灯させよう ref: http://qiita.com/oasynnoum@github/items/91aed309bd9de8af8d0a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "phpmake/example-blink-led", | |
| "type": "project", | |
| "require": { | |
| "phpmake/firmata": "dev-master" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ composer install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ php blink-led.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment