我有这个脚本来检查的GPIO引脚的状态:
<script type="text/javascript">
$(document).ready(function () {
// This is the init function
// Runs when the page has completed loading
$('#statusCheck').click(function() {
//console.log('checking status');
$.ajax({
url: "check.php",
success: function (data) {
if(data != 1 )
{
// Door is closed
$('#sttext').html('<span style= color:green;>Closed</span>');
}
else if(data == 1)
{
// Door is open
$('#sttext').html('<span style= color:green;>Open</span>Open');
}
//$('#debug').html(''); // Print null string to clear message
//$('#debug').html(data); // Debug message, printing out read back status.
}
});
});
});
</script>
连接到一个按钮,跨度:
<strong>Status: <span id="sttext"></span></strong></p>
<button id="statusCheck" class="green-btn">Check Status </button>
检查PHP代码为:
<?php
system(exec ( "GPIO read 1", $status ));
system(print_r ( $status ));
?>
我一直outputing关闭,但引脚设置为1 ...当我从运行在树莓派的命令行它给了我1读....但是PHP脚本,我认为是不工作...