Hey,
ja das wäre nett.
Der Code ist der hier:
Code:
<html>
<head>
<title>
Raspberry Pi Webserver
</title>
</head>
<h1>
<font color="red">
Raspberry Pi Webserver
</font>
</h1>
<body>
<form action="IO.php" method ="post">
<input type="Checkbox" name="gpio0" value="0">GPIO 0<br>
<input type="Checkbox" name="gpio1" value="1">GPIO 1<br>
<input type="Checkbox" name="gpio4" value="4">GPIO 4<br>
<input type="Checkbox" name="gpio7" value="7">GPIO 7<br>
<input type="Checkbox" name="gpio8" value="8">GPIO 8<br>
<input type="Checkbox" name="gpio9" value="9">GPIO 9<br>
<input type="Checkbox" name="gpio10" value="10">GPIO 10<br>
<input type="Checkbox" name="gpio11" value="11">GPIO 11<br>
<input type="Checkbox" name="gpio14" value="14">GPIO 14<br>
<input type="Checkbox" name="gpio15" value="15">GPIO 15<br>
<input type="Checkbox" name="gpio17" value="17">GPIO 17<br>
<input type="Checkbox" name="gpio18" value="18">GPIO 18<br>
<input type="Checkbox" name="gpio21" value="21">GPIO 21<br>
<input type="Checkbox" name="gpio22" value="22">GPIO 22<br>
<input type="Checkbox" name="gpio23" value="23">GPIO 23<br>
<input type="Checkbox" name="gpio24" value="24">GPIO 24<br>
<input type="Checkbox" name="gpio25" value="25">GPIO 25<br>
<p>
<input type="Submit" name="IO abfragen" value="I/O Status">
<input type="Submit" name="IO setzen" value="I/O setzen">
</form>
<?php
if (isset($_REQUEST['IO abfragen']));
{
if (isset($_POST["gpio0"]))
{
$val_gpio0 = trim(@shell_exec("cat /sys/class/gpio/gpio0/value"));
$dir_gpio0 = trim(@shell_exec("cat /sys/class/gpio/gpio0/direction"));
echo "<u>GPIO 0: </u><br/>";
if ($val_gpio0 == 0)
{
echo('<img src="LED_off.png" alt="LED_off_GPIO0">');
}
elseif ($val_gpio0 == 1)
{
echo('<img src="LED_on.png" alt="LED_on_GPIO0">');
}
echo "<br/>";
echo "Value: ", $val_gpio0;
echo "<br/>";
echo "Direction: ", $dir_gpio0;
echo "<br/>";
}
if (isset($_POST["gpio1"]))
{
$val_gpio1 = trim(@shell_exec("cat /sys/class/gpio/gpio1/value"));
$dir_gpio1 = trim(@shell_exec("cat /sys/class/gpio/gpio1/direction"));
echo "<u>GPIO 1: </u><br/>";
if ($val_gpio1 == 0)
{
echo('<img src="LED_off.png" alt="LED_off_GPIO0">');
}
elseif ($val_gpio1 == 1)
{
echo('<img src="LED_on.png" alt="LED_on_GPIO0">');
}
echo "<br/>";
echo "Value: ", $val_gpio1;
echo "<br/>";
echo "Direction: ", $dir_gpio1;
echo "<br/>";
}
if (isset($_POST["gpio4"]))
{
$val_gpio4 = trim(@shell_exec("cat /sys/class/gpio/gpio4/value"));
$dir_gpio4 = trim(@shell_exec("cat /sys/class/gpio/gpio4/direction"));
echo "<u>GPIO 4: </u><br/>";
if ($val_gpio4 == 0)
{
echo('<img src="LED_off.png" alt="LED_off_GPIO0">');
}
elseif ($val_gpio4 == 1)
{
echo('<img src="LED_on.png" alt="LED_on_GPIO0">');
}
echo "<br/>";
echo "Value: ", $val_gpio4;
echo "<br/>";
echo "Direction: ", $dir_gpio4;
echo "<br/>";
}
}
if (isset($_REQUEST['IO setzen']));
{
if (isset($_POST["gpio0"]))
{
shell_exec("echo \"1\" > /sys/class/gpio/gpio0/value");
}
}
?>
</body>
</html>
Und diese Zeile macht Probleme:
Code:
if (isset($_REQUEST['IO setzen']));
{
if (isset($_POST["gpio0"]))
{
shell_exec("echo \"1\" > /sys/class/gpio/gpio0/value");
}
}
Shell_exec funktioniert....verwende es ja oben. Aber wieso geht die LED dann nicht an >.<?
Lesezeichen