Raspberry Pi Web Server with RGB LED Feedback
Sat, 23 Feb 2013
The Raspberry Pi makes a great low-power web server that you can place on your desk. However, if you run it without a screen attached it doesn't really give you much in the way of visual feedback when it is being accessed. I thought would have a go at changing this by seeing if I could connect some coloured LEDs to my R-Pi and write a simple PHP lighting controller for it.
When hunting around for suitable hardware I found an excellent £14.49 kit from Meltwater that lets you connect up to five RGB LEDs to the Pi's GPIO port. It's a pretty simple board to build and comes with some example Shell and Python scripts to help you test it. In order to interface it to my web server software I installed the ronanguilloux / php-gpio library. I then rewrote the Meltwater Shell script in PHP with the php-gpio library - making sure that I sent exactly the same GPIO commands to the Meltwater board. Hey presto, it worked! A few more tweaks later and I now have my own PHP library for setting the colours of any of the five LEDs whenever I want to. All this was done within a couple of hours of receiving the Meltwater RGB-LED kit.
By adding a few lines of code to the bottom of my PHP web pages I can now blink the LEDs whenever a page is accessed, report on error or success states, or simply create PHP pages that trigger lighting sequences just for the fun of it. Isn't the Raspberry Pi great :-)