hyle: Das hat leider keinen Erfolg gebracht. Ich habe die GPIOs jetzt beim starten als Ausgang definiert. Aber damit komme ich auch nicht weiter. Ist meine Abfrage der Buttons bzw. der Ansteuerung der GPIOs so korrekt?
PHP
<?php
shell_exec('usr/local/bin/gpio -g mode 4 out');
shell_exec('usr/local/bin/gpio -g mode 17 out');
shell_exec('usr/local/bin/gpio -g mode 22 out');
shell_exec('usr/local/bin/gpio -g mode 27 out');
shell_exec('usr/local/bin/gpio -g mode 14 out');
shell_exec('usr/local/bin/gpio -g mode 15 out');
shell_exec('usr/local/bin/gpio -g write 14 1 & usr/local/bin/gpio write 15 1');
sleep(1);
shell_exec('usr/local/bin/gpio -g write 14 0 & usr/local/bin/gpio write 15 0');
if(isset($_POST['button'])) {
if($_POST['btn'] == 'Vorwaerts') {
$output = shell_exec("/usr/local/bin/gpio -g write 17 1 & /usr/local/bin/gpio -g write 4 0 & /usr/local/bin/gpio -g write 22 1 & /usr/local/bin/gpio -g write 27 0");
}
elseif ($_POST['btn'] == 'Stop') {
$output = shell_exec("/usr/local/bin/gpio -g write 17 0 & /usr/local/bin/gpio -g write 4 0 & /usr/local/bin/gpio -g write 22 0 & /usr/local/bin/gpio -g write 27 0");
}
elseif ($_POST['btn'] == 'Rueckwaerts') {
$output = shell_exec("/usr/local/bin/gpio -g write 4 1 & /usr/local/bin/gpio -g write 17 0 & /usr/local/bin/gpio -g write 27 1 & /usr/local/bin/gpio -g write 22 0");
}
elseif ($_POST['btn'] == 'Links') {
$output = shell_exec("/usr/local/bin/gpio -g write 17 1 & /usr/local/bin/gpio -g write 4 0 & /usr/local/bin/gpio -g write 22 0 & /usr/local/bin/gpio -g write 27 0");
}
elseif ($_POST['btn'] == 'Links_drehen') {
$output = shell_exec("/usr/local/bin/gpio -g write 17 1 & /usr/local/bin/gpio -g write 4 0 & /usr/local/bin/gpio -g write 22 0 & /usr/local/bin/gpio -g write 27 1");
}
elseif ($_POST['btn'] == 'Rechts') {
$output = shell_exec("/usr/local/bin/gpio -g write 22 1 & /usr/local/bin/gpio -g write 4 0 & /usr/local/bin/gpio -g write 17 0 & /usr/local/bin/gpio -g write 27 0");
}
elseif ($_POST['btn'] == 'Rechts_drehen') {
$output = shell_exec("/usr/local/bin/gpio -g write 22 1 & /usr/local/bin/gpio -g write 4 1 & /usr/local/bin/gpio -g write 17 0 & /usr/local/bin/gpio -g write 27 0");
}
elseif ($_POST['btn'] == 'Lichtan') {
$output = shell_exec("/usr/local/bin/gpio -g write 14 1 & /usr/local/bin/gpio -g write 15 1");
}
elseif ($_POST['btn'] == 'Lichtaus') {
$output = shell_exec("/usr/local/bin/gpio -g write 14 0 & /usr/local/bin/gpio -g write 15 0");
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<title>RaspBot Version 1.0</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="kopfbereich">
<h1> RaspBot Rev. 1.0 </h1>
</div>
<div id="webcam">
<iframe src="http://192.168.178.15:8081" frameborder="1" scrolling="No" width="320px" height="240px"></iframe>
</div>
<div id="ausgabe">
<h2> <font size="2"> RaspBot Fahrtrichtung: <?php echo $output ?> ! </font> </h2>
</div>
<div id="steuerung_mitte">
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="POST">
<p><button type="submit" name="btn" value="Vorwaerts" style="width:100px; height:40px; background-color:#209b3d;">Vorwaerts</button></p>
<p><button type="submit" name="btn" value="Stop" style="width:100px; height:40px; background-color:#209b3d;">Stop</button></p>
<p><button type="submit" name="btn" value="Rueckwaerts" style="width:100px; height:40px; background-color:#209b3d;">Rueckwaerts</button></p>
</form>
</div>
<div id="steuerung_rechts">
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="POST">
<p><button type="submit" name="btn" value="Rechts" style="width:100px; height:40px; background-color:#209b3d;">Rechts</button></p>
<p><button type="submit" name="btn" value="Rechts_drehen" style="width:100px; height:40px; background-color:#209b3d;">Rechts drehen</button></p>
</form>
</div>
<div id="steuerung_links">
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="POST">
<p><button type="submit" name="btn" value="Links" style="width:100px; height:40px; background-color:#209b3d;">Links</button></p>
<p><button type="submit" name="btn" value="Links_drehen" style="width:100px; height:40px; background-color:#209b3d;">Links drehen</button></p>
</form>
</div>
<div id="steuerung_licht">
<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="POST">
<p><button type="submit" name="btn" value="Lichtan" style="width:100px; height:40px; background-color:#209b3d;">Licht an</button></p>
<p><button type="submit" name="btn" value="Lichtaus" style="width:100px; height:40px; background-color:#209b3d;">Licht aus</button></p>
<p><button type="submit" name="btn" value="Kamera_aktvieren" style="width:100px; height:40px; background-color:#209b3d;">Kamera aktivieren</button></p>
</form>
</div>
<div id="fussbereich">
<h1> </h1>
</div>
</body>
</html>
Alles anzeigen