You don't say whether you have written any code to exercise the GPIO and your electronics. If not, then you need to do this before any exact detail could be given to the way you might put your server together. If you have written some code, and you wish to re-use that and integrate into your plans, then this will determine some routes for you.
Your code could be a bash script, in some ways the most basic, through to C++ or Java at the other end of the spectrum. These all have their relative merits, and downsides too, it depends on where you are and what sort of learning curve you wish to embark upon.
If you were to start with a bash script you should consider installing wiringPi
https://projects.drogon.net/raspberry-p ... d-install/, this will introduce a new command (gpio) which will provide access to the GPIO pins. This will simplify the look of your script by de-cluttering it of sudo, redirection and so on, making it easier to develop and appreciate what's going on. It hides all the access to the underlying system registers, which may be what you'd like to see, so it may not be for you. So develop a script to do something simple, maybe
where it accepts a pin number (-p 10) and sets a state (-s on). Not the simplest possible, but a few twists like getting options into the script. Obviously you can add more things, like check that the stated pin is valid, the state is only on or off, is case-insensitve and so on, just to brush up the script writing skills.
The script will be invoked as a CGI by the web-server. So you will need Apache2 installed (other ones are available if required) and depending on your distro of choice this may well already be done. This server will define a directory where web pages are to be sourced from, it might be something like /var/www (or not), check you own documentation.
To develop web pages you can use your favourite text editor (vi, vim, nano,...). You could write these on a remote system with more familiar tools and then copy the pages across to the correct location on your Pi.
Create a simply piece of HTML containing some text. Install it to the correct location and see that you can access it will a browser. You may decide you want a Pi local browser, but personally I'd use one on a remote system. Point the browser at your web page and see the result.
You can now think about your LED-activatiing script and running it as a CGI with URLS like
Code: Select all
http://mypi.local/cgi-bin/activeLED.sh?p=10&s=on
The bit from ? onwards in known as the QUERY_STRING and this can be accessed by your script at run-time. I've made the arguments roughly the same as before but the code would have to be modified to handle the QUERY_STRING rather that accept command line arguments. Its not beyond the wit of man to write it so it handles both! Take a look at
http://www.yolinux.com/TUTORIALS/BashShellCgi.html for pointers on how to get the CGI up and running. The installation of your cgi script should be verified in the documentation of for your web-server; this scripts can pose a security risk and so are usually coralled quite strongly.
You can write web pages to include things like:
Code: Select all
<a href="http://mypi.local/cgi-bin/activeLED.sh?p=10&s=off">Pin 10 OFF</a>
<a href="http://mypi.local/cgi-bin/activeLED.sh?p=10&s=on">Pin 10 ON</a>
Clicking the line will result in the LED being turned oon or off
You will need to look at Javascript in order to develop the sort of pages that are in your minds eye. It would be tedious to write code for the above for 4 pins (say) and you could do the same with option menu, check/radio boxes and so on. These can be constructed in basic Javascript, or you might take a look at JQuery, a library of wondrous things you never new you wanted!
And then you're away and running!
HTH