I'm doing a little project with a rRspBerry Pi 3 that consists, among other things, of controlling some outputs through a web page. I needed to be able to know and print on the page what the status of these outputs at a given time. I have, for example, a button to turn on an LED and another button to turn off, but I need to print in a text box if the LED is on or off and let or not turn the LED on or off depending on its state.
To read the status I can use theexec("gpio read ".$i, $status);
function where $i
is the pin I want to read and $status
is where it saves the state of the pin, but I do not know how to include it in my web page, how do I know where to go to see an example?
Code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<article>
<div id="Janelas">
<h1>Sistemas de Climatização</h1>
<p>Soalho radiante</p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script><scripttype="text/javascript">// <![CDATA[
$(document).ready(function() {
$('#ligar').click(function(){
var a= new XMLHttpRequest();
a.open("GET", "soalholigar.php"); a.onreadystatechange=function(){
if(a.readyState==4){ if(a.status ==200){
} else alert ("http error"); } }
a.send();
});
});
$(document).ready(function() {
$('#desligar').click(function(){
var a= new XMLHttpRequest();
a.open("GET", "soalhodesligar.php"); a.onreadystatechange=function(){
if(a.readyState==4){ if(a.status ==200){
} else alert ("http error"); } }
a.send();
});
});
</script>
<input type="button" id="ligar" value="Ligar">
<input type="button" id="desligar" value="Desligar">
<center>
<input type="text" size="5" name="textgol" value="0">
</center>
<p>ZONA 2.</p>
<input type="button" name="botao-ligar" value="Ligar">
<input type="button" name="botao-desligar" value="Desligar">
<p>ZONA 3.</p>
<input type="button" name="botao-ligar" value="Ligar">
<input type="button" name="botao-desligar" value="Desligar">
<p>ZONA 4.</p>
<input type="button" name="botao-ligar" value="Ligar">
<input type="button" name="botao-desligar" value="Desligar">
<br/>
<br/>
<a href="javascript:window.history.go(-1)">Voltar</a>
</body>
</html>