A
Anonymous
Guest
Hi ,
I am new to PHP programming .Here i am trying to run GPIO pins of raspberry pi with php . I have taken the code from : http://www.raspberry-pi-geek.com/Archive/2014/07/PHP-on-Raspberry-Pi. to start
I want to have multiple buttons for GPIO ON/OFF like for example
button1,button2,button3
1. if i press submit button1 for on - the display should show the result in Textbox as " ON ".
2. if i press submit button2 for on - the display should show the result in Textbox as " ON ".
3. if i press submit button3 for off -the display should show the result in Textbox as " OFF ".
Problem:
what should i do to keep the textbox text unchanged after clicking on any buttons or reloading of same page.
if light is ON means its ON it should not show OFF after reloading of same page.
HTML
<form method="get" action="gpio.php">
<input type="submit" value="ON" name="on">
<input type="submit" value="OFF" name="off">
</form>
PHP
<?php
$setmode17 = shell_exec("/usr/local/bin/gpio -g mode 17 out");
if(isset($_GET['on'])){
$gpio_on = shell_exec("/usr/local/bin/gpio -g write 17 1");
echo "LED is on";
}
else if(isset($_GET['off'])){
$gpio_off = shell_exec("/usr/local/bin/gpio -g write 17 0");
echo "LED is off";
}
?>
Thanks
Atila
I am new to PHP programming .Here i am trying to run GPIO pins of raspberry pi with php . I have taken the code from : http://www.raspberry-pi-geek.com/Archive/2014/07/PHP-on-Raspberry-Pi. to start
I want to have multiple buttons for GPIO ON/OFF like for example
button1,button2,button3
1. if i press submit button1 for on - the display should show the result in Textbox as " ON ".
2. if i press submit button2 for on - the display should show the result in Textbox as " ON ".
3. if i press submit button3 for off -the display should show the result in Textbox as " OFF ".
Problem:
what should i do to keep the textbox text unchanged after clicking on any buttons or reloading of same page.
if light is ON means its ON it should not show OFF after reloading of same page.
HTML
<form method="get" action="gpio.php">
<input type="submit" value="ON" name="on">
<input type="submit" value="OFF" name="off">
</form>
PHP
<?php
$setmode17 = shell_exec("/usr/local/bin/gpio -g mode 17 out");
if(isset($_GET['on'])){
$gpio_on = shell_exec("/usr/local/bin/gpio -g write 17 1");
echo "LED is on";
}
else if(isset($_GET['off'])){
$gpio_off = shell_exec("/usr/local/bin/gpio -g write 17 0");
echo "LED is off";
}
?>
Thanks
Atila