Python - 使用php引导控件

时间:2017-06-20 14:23:30

标签: php iot led

我想通过网页控制我的LED照明。我按照YouTube教程,它适用于pinon.php和pinoff.php。

但是,它对control.php不起作用,有人知道原因吗?

pinon.php

<?php
system("gpio -g mode 18 out");
system("gpio -g write 18 1");
?>

pinoff.php

<?php
system("gpio -g mode 18 out");
system("gpio -g write 18 0");
?>

control.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
                $('#clickON').click(function(){
                        var a = new XMLHttpRequest();
                        a.open("GET","pinon.php");
                        a.onreadystatechange=function(){
                                if(a.readyState==4){
                                        if(a.status == 200){
                                        }
                                        else alert("HTTP ERROR");
                                }
                        }
                        a.send();
                });
                $('#clickOFF').click(function(){
                        var a = new XMLHttpRequest();
                        a.open("GET","pinoff.php");
                        a.onreadystatechange=function(){
                                if(a.readyState==4){
                                        if(a.status == 200){
                                        }
                                        else alert("HTTP ERROR");
                                }
                        }
                        a.send();
                });
        });
    </script>
    <title>Pi controller</title>
</head>
<body>
    <button type="button" id="clickON">ON</button><br>
    <button type="button" id="clickOFF">OFF</button><br>
</body>
</html>

教程链接:Making Raspberry Pi Web Controls

0 个答案:

没有答案