當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Board::getPin方法代碼示例

本文整理匯總了PHP中Board::getPin方法的典型用法代碼示例。如果您正苦於以下問題:PHP Board::getPin方法的具體用法?PHP Board::getPin怎麽用?PHP Board::getPin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Board的用法示例。


在下文中一共展示了Board::getPin方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: writePins

function writePins(array $rgb)
{
    static $pi, $r, $g, $b;
    if ($pi === null) {
        $pi = new Board();
        $r = $pi->getPin(0)->mode(Pin::SOFT_PWM_OUT)->softPwmWrite(100);
        $g = $pi->getPin(1)->mode(Pin::SOFT_PWM_OUT);
        $b = $pi->getPin(2)->mode(Pin::SOFT_PWM_OUT);
    }
    $r->softPwmWrite($rgb[0]);
    $g->softPwmWrite($rgb[1]);
    $b->softPwmWrite($rgb[2]);
}
開發者ID:amnuts,項目名稱:phpiwire,代碼行數:13,代碼來源:rgbled.php

示例2: Board

 *
 * Example of using software PWM to pulse an LED
 *
 * @author Andrew Collington, andy@amnuts.com
 * @version 0.2.0
 * @link https://github.com/amnuts/phpiwire
 * @license MIT, http://acollington.mit-license.org/
 */
namespace Phpiwire;

if (PHP_SAPI !== 'cli') {
    echo 'Sorry, you can only use this via the command line.';
    return;
}
set_time_limit(0);
echo "Raspberry Pi pulse - use ^C to stop\n";
$pi = new Board();
$p = $pi->getPin(0)->mode(Pin::SOFT_PWM_OUT);
$sleep = 20000;
$pwmValue = 100;
// 0 min, 100 max
while (true) {
    for ($i = 0; $i <= $pwmValue; ++$i) {
        $p->softPwmWrite($i);
        usleep($sleep);
    }
    for ($i = $pwmValue; $i > 0; --$i) {
        $p->softPwmWrite($i);
        usleep($sleep);
    }
}
開發者ID:amnuts,項目名稱:phpiwire,代碼行數:31,代碼來源:softpwm.php

示例3: Board

<?php

/**
 * Phpiwire: A PHP wrapper for wiringPi
 *
 * Example of resetting the GPIO pins
 *
 * @author Andrew Collington, andy@amnuts.com
 * @version 0.2.0
 * @link https://github.com/amnuts/phpiwire
 * @license MIT, http://acollington.mit-license.org/
 */
namespace Phpiwire;

if (PHP_SAPI !== 'cli') {
    echo 'Sorry, you can only use this via the command line.';
    return;
}
echo "Raspberry Pi - all pins reset to LOW\n";
$pi = new Board();
foreach (range(0, 7) as $pin) {
    $p = $pi->getPin($pin)->mode(Pin::OUTPUT);
    $p->write(Pin::LOW);
}
開發者ID:amnuts,項目名稱:phpiwire,代碼行數:24,代碼來源:reset.php

示例4: Board

<?php

/**
 * Phpiwire: A PHP wrapper for wiringPi
 *
 * Checking pin status
 *
 * @author Andrew Collington, andy@amnuts.com
 * @version 0.2.0
 * @link https://github.com/amnuts/phpiwire
 * @license MIT, http://acollington.mit-license.org/
 */
namespace Phpiwire;

$pi = new Board();
$p = $pi->getPin(0)->mode(Pin::OUTPUT);
echo $p, "\n";
if ($p->read() == Pin::LOW) {
    echo "Setting {$p->getId()} to HIGH\n\n";
    $p->write(Pin::HIGH);
} else {
    echo "Setting {$p->getId()} to LOW\n\n";
    $p->write(Pin::LOW);
}
echo $p, "\n";
開發者ID:amnuts,項目名稱:phpiwire,代碼行數:25,代碼來源:pin.php

示例5: Board

 *
 * @author Andrew Collington, andy@amnuts.com
 * @version 0.2.0
 * @link https://github.com/amnuts/phpiwire
 * @license MIT, http://acollington.mit-license.org/
 */
namespace Phpiwire;

if (PHP_SAPI !== 'cli') {
    echo 'Sorry, you can only use this via the command line.';
    return;
}
set_time_limit(0);
echo "Raspberry Pi pulse - use ^C to stop\n";
$pi = new Board();
$p = $pi->getPin(1)->mode(Pin::PWM_OUT);
$p->pwmWrite(0);
$sleep = 500;
$pwmValue = 1024;
// 0 min, 1024 max
while (true) {
    for ($i = 0; $i <= $pwmValue; ++$i) {
        $p->pwmWrite($i);
        usleep($sleep);
    }
    sleep(1);
    for ($i = $pwmValue; $i > 0; --$i) {
        $p->pwmWrite($i);
        usleep($sleep);
    }
}
開發者ID:amnuts,項目名稱:phpiwire,代碼行數:31,代碼來源:pulse.php


注:本文中的Board::getPin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。