I was trying to execute gpio[bash shell] command from PHP. I was executing properly as expected, but when I cross check the same with bash shell pin 0 values got changed. 1. input url :gpio.php?value=4 [working and output displayed as expected toggle happens] 2. bash shell : #gpio read 4 [doesn't change the value, only pin 0 changes]
$num = intval($_GET['value']);
echo $num;
if (isset($num)){
$read = shell_exec('gpio read ".$num."');
if($read == 0) {
echo "OFF";
$re = shell_exec('gpio write ".$num." 1');}
if($read == 1) {
echo "ON";
$re = shell_exec('gpio write ".$num." 0');}
$read = shell_exec('gpio read ".$num."');
if($read == 0) {echo " --> OFF";}
if($read == 1) {echo " --> ON";}
}
else {echo "No value Found";}
Let me known were I'm wrong...?