====== LED from web page ====== ===== Hardware ===== {{:cimg8954_.jpg?nolink&|}} Connect LED between **GND** and **GPIO9** (CTS) pins. ===== Prepare firmware ===== **Don't install LUCI (or set different server port number in lighthttpd.conf)** Languages PHP php5 php5-fastcgi php5-mod-json php5-mod-sockets Network Web Servers/Proxies lighttpd lighttpd-mod-cgi lighttpd-mod-fastcgi lighttpd-mod-simple-vhost ===== On Carambola ===== ==== Firewall ==== Edit wan zone, to allow incoming connections. vi /etc/config/firewall config zone option name wan option network 'wan' option input ACCEPT option output ACCEPT option forward REJECT option masq 1 option mtu_fix 1 /etc/init.d/firewall restart ==== lighttpd.conf ==== vi /etc/lighttpd/lighttpd.conf server.modules = ( "mod_cgi" ) server.network-backend = "write" server.document-root = "/www/" server.errorlog = "/var/log/lighttpd/error.log" index-file.names = ( "index.html", "default.html", "index.htm", "default.htm" ) ## mimetype mapping mimetype.assign = ( ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".css" => "text/css", ".html" => "text/html", ".htm" => "text/html", ".js" => "text/javascript" ) $HTTP["url"] =~ "\.pdf$" { server.range-requests = "disable" } static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) server.pid-file = "/var/run/lighttpd.pid" server.upload-dirs = ( "/tmp" ) cgi.assign = ( ".sh" => "/bin/sh", ".php" => "/usr/bin/php-cgi") ==== lighthttp stuff ==== Reload liththttp server. /etc/init.d/lighttpd reload View error log. cat /var/log/lighttpd/error.log ==== /www/leds.php ==== "; exec("echo 9 > /sys/class/gpio/export", $output, $return); exec("echo out > /sys/devices/virtual/gpio/gpio9/direction", $output, $return); } if ($_POST['led']==2) { echo "Led ON"; exec("echo 1 > /sys/devices/virtual/gpio/gpio9/value", $output, $return); } if ($_POST['led']==1) { echo "Led OFF"; exec("echo 0 > /sys/devices/virtual/gpio/gpio9/value", $output, $return); } ?>


===== HTTP testing ===== After you open this web page for the first time, it initializes GPIO. {{:2013-03-17 14_33_03.png?nolink&|}} After you press button it informs what's the status of the LED.