Managing an LED in PHP
Now it's time to see how to manage our LED using the PHP language.
There are two different possibilities to do this: the first one is to use the LAMP (Linux-Apache-MySQL-PHP) system we set up in The LAMP suite section of Chapter 1, Installing the Developing System, while the second one is to use the PHP built-in web server.
The LAMP solution
This is the easiest and most classic way to implement a common web application. We just need a PHP script where we can implement our LED management. So let's start with writing some code!
In the first step, we must create a file named turn.php
in the /var/www/
directory of the BeagleBone Black with the following content:
<?php # 1st part - Global defines & functions define("value_f", "/sys/class/gpio/gpio66/value"); # 2nd part - Get the current led status $led_status = intval(file_get_contents(value_f)); # 3rd part - Render the led status by HTML code ?...