Created
December 16, 2013 12:50
-
-
Save kahagon/7986472 to your computer and use it in GitHub Desktop.
php-gpio の API の使用例です。
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 'vendor/autoload.php'; | |
| use PhpGpio\Gpio; | |
| $pin = 25; | |
| print "Setting up pin $pin" . PHP_EOL; | |
| $gpio = new GPIO(); | |
| $gpio->setup($pin, "out"); | |
| for ($i = 0; $i < 20; $i++) { | |
| print "Turning on pin $pin" . PHP_EOL; | |
| $gpio->output($pin, 1); | |
| print "Sleeping" . PHP_EOL; | |
| sleep(1); | |
| print "Turning off pin $pin" . PHP_EOL; | |
| $gpio->output($pin, 0); | |
| print "Sleeping" . PHP_EOL; | |
| sleep(1); | |
| } | |
| print "Unexporting all pins" . PHP_EOL; | |
| $gpio->unexportAll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment