Just performing a simple turn on LED via web page script I found online and it would seem that echo commands are being executed after the shell_exec commands that follow them, is there a reason for this? Basically the on and off are quick enough not to really notice but the blinking echo only comes on after the blinking sequence has finished.
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>WIFI Controlled LED</title>
</head>
<body>
<center><b><font size = '20'>Control LED:</b>
<form method="get" action="index.php">
<input type="submit" style = "font-size: 16 pt" value="OFF" name="off">
<input type="submit" style = "font-size: 16 pt" value="ON" name="on">
<input type="submit" style = "font-size: 16 pt" value="BLINK" name="blink">
</form>
<?php
shell_exec("/usr/local/bin/gpio -g mode 17 out");
if(isset($_GET['off']))
{
echo "LED is off";
shell_exec("/usr/local/bin/gpio -g write 17 0");
}
else if(isset($_GET['on']))
{
echo "LED is on";
shell_exec("/usr/local/bin/gpio -g write 17 1");
}
else if(isset($_GET['blink']))
{
echo "LED is blinking";
for($x = 0;$x<=4;$x++)
{
shell_exec("/usr/local/bin/gpio -g write 17 1");
sleep(1);
shell_exec("/usr/local/bin/gpio -g write 17 0");
sleep(1);
}
}
?>
</center></font>
</body>
</html>