Python - control with php
I would like to control my LED lighting through a webpage. I am following YouTube tutorial, it works great for pinon.php and pinoff.php.
However, this doesn't work for control.php, does anyone know the reason?
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>
Tutorial Link: Building Raspberry Pi Web Controls
+3
source to share
No one has answered this question yet