I have a PHP script in which I control LEDs over wifi on Raspberry.
$fileName = __DIR__.'/txt/led2.txt';
if (!file_exists($fileName) || (file_get_contents($fileName) !== '1' && file_get_contents($fileName) !== '0')) {
file_put_contents($fileName, '1');
}
if (isset($_GET['on4']) && file_get_contents($fileName) === '1') {
shell_exec("/usr/local/bin/gpio -g write 15 1");
file_put_contents($fileName, '0');
}
else if (isset($_GET['on4']) && file_get_contents($fileName) === '0') {
shell_exec("/usr/local/bin/gpio -g write 15 0");
file_put_contents($fileName, '1');
}
Basically If I press button, script will replace variable in file, when it is on, variable in file = 0 and when it is off, its equals to 1.
I need to show the current status of the LEDs on my web UI. Is it posible? Now I only know if the echo shows 1 or 0, could not it be replaced by some picture or text?