Hi!
ich habe per PHP erfolgreich eine Steuerung für mein PicoBorg geschrieben:
PHP
<?php
if (isset($_POST['GPIO4-1']))
{
shell_exec("gpio -g write 4 1");
}
if (isset($_POST['GPIO4-0']))
{
shell_exec("gpio -g write 4 0");
}
if (isset($_POST['GPIO7-1']))
{
shell_exec("gpio -g write 7 1");
}
if (isset($_POST['GPIO7-0']))
{
shell_exec("gpio -g write 7 0");
}
if (isset($_POST['GPIO8-1']))
{
shell_exec("gpio -g write 8 1");
}
if (isset($_POST['GPIO8-0']))
{
shell_exec("gpio -g write 8 0");
}
if (isset($_POST['GPIO18-1']))
{
shell_exec("gpio -g write 18 1");
}
if (isset($_POST['GPIO18-0']))
{
shell_exec("gpio -g write 18 0");
}
?>
<html>
<head>
<title>Raspberry Pi GPIO</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="icon" type="image/png" href="img/favicon.png" />
<style type="text/css">
body {
background-image: url(img/bg.jpg);
background-repeat: repeat-x;
}
.all {
width: 100%;
}
</style>
</head>
<body>
<div class="all">
<div align="center">
<h1>Raspberry Pi GPIO</h1>
</div>
<div align="center">
<div>
<form method="post">
<p>GPIO 4 <button name="GPIO4-1" style="width: 50px; background-image: url(img/bbg.jpg)">ein</button> <button name="GPIO4-0" style="width: 50px; background-image: url(img/bbgr.jpg)">aus</button></p>
<p>GPIO 7 <button name="GPIO7-1" style="width: 50px; background-image: url(img/bbg.jpg)">ein</button> <button name="GPIO7-0" style="width: 50px; background-image: url(img/bbgr.jpg)">aus</button></p>
<p>GPIO 8 <button name="GPIO8-1" style="width: 50px; background-image: url(img/bbg.jpg)">ein</button> <button name="GPIO8-0" style="width: 50px; background-image: url(img/bbgr.jpg)">aus</button></p>
<p>GPIO 18 <button name="GPIO18-1" style="width: 50px; background-image: url(img/bbg.jpg)">ein</button> <button name="GPIO18-0" style="width: 50px; background-image: url(img/bbgr.jpg)">aus</button></p>
</form>
</div>
</div>
<div align="center">
<p>© 2013 <a href="http://go-seven.de">Pascal Tippelt</a></p>
</div>
</div>
</body>
</html>
Alles anzeigen
Vielleicht nicht die sauberste und speichersparendste Möglichkeit, aber sie funktioniert. nun fehlt mir aber noch der "Rückkanal" - sprich in der PHP-Seite soll angezeigt werden, ob (zum Beispiel) der GPIO-out-Port 4 high oder low ist (am besten durch ein kleines rundes Icon, welches die Farbe wechselt)...
Ich hoffe ihr könnt mir helfen!
MfG Pascal
Okay - mittlerweile habe ich es selber gelöst...:
Das gibt zwar "nur" eine 1 oder 0 aus, das reicht aber vorerst. Das mit dem Icon kann mir ja vllt jmd erklären?