用于树莓派echo命令的php脚本缓慢

时间:2018-12-17 18:33:32

标签: php raspberry-pi

仅通过我在网上找到的网页脚本执行简单的打开LED指示灯,似乎在跟随它们的shell_exec命令之后执行了echo命令,这是否有原因?基本上,打开和关闭的速度足够快,无法真正注意到,但是闪烁的回声仅在闪烁序列完成后才出现。

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>WIFI Controlled LED</title>
</head>
       <body>
       <center><b><font size = '20'>Control LED:</b>       
         <form method="get" action="index.php">                 
                 <input type="submit" style = "font-size: 16 pt" value="OFF" name="off">
                 <input type="submit" style = "font-size: 16 pt" value="ON" name="on">
                 <input type="submit" style = "font-size: 16 pt" value="BLINK" name="blink">
         </form>
         <?php
         shell_exec("/usr/local/bin/gpio -g mode 17 out");
         if(isset($_GET['off']))
         {
        echo "LED is off";
        shell_exec("/usr/local/bin/gpio -g write 17 0");
         }
    else if(isset($_GET['on']))
    {
        echo "LED is on";
        shell_exec("/usr/local/bin/gpio -g write 17 1");
    }
    else if(isset($_GET['blink']))
    {
        echo "LED is blinking";
        for($x = 0;$x<=4;$x++)
        {
            shell_exec("/usr/local/bin/gpio -g write 17 1");
            sleep(1);
            shell_exec("/usr/local/bin/gpio -g write 17 0");
            sleep(1);
        }
    }
        ?>
   </center></font>
   </body>
 </html>

0 个答案:

没有答案