Introduction: Web Controlled Holiday House Lighting
This is an extension to a previous Instructable on Permanent Holiday LED House Lighting.
Now that all the LEDs are wired up, the challenge is getting out there each holiday to change the pattern. You could add some push buttons to choose between programs, but since I manage TeleToyland for fun, and connect things to the web a lot, why not make the house web controlled!
The previous Instructable shows how to do all the wiring. This one mashes it up with the LED Tower Instructable to allow web control of the LED animations. The concepts could be applied to other projects. You can try the LED Tower any time online, but I will not make the house a project open to the web - am just using it for my ease of setup.
This project adds a Wifi shield to the Arduino from before - I used a CC3000 shield since it's less expensive, and it seems to work well. I also have a Unix web host setup that allows PHP web programming, and a MySQL database to hold the configurations. The LED Tower works in a similar way, and mentions other ways to do this kind of project. It could all fit on an Arduino if you want to have the Arduino respond to web requests directly - the DB is not a requirement.
Step 1: Parts
To add the web control to the previous Instructable, not many new parts are needed - just a CC3000 Wifi Shield. This shield is less expensive than the Arduino Wifi Shield, and Adafruit provides code samples that were sufficient for this project.
You will also want some kind of web hosting that allows PHP and a MySQL database
Step 2: Code
The web server side of this project is very similar to the LED Tower Instructable. There are many ways to approach this kind of project, and this one works without configuring routers and Dynamic DNS, but does require an ISP web host with PHP and a MySQL database, which are common.
The core of this system is a MySQL database, and the attached SQL script will create the structure used by the code. It's a very simple schema - just one table with a field for the commands along with index/key and timestamp fields.
The page shows a form for adding commands, processes any removal commands, and shows the list of current commands all in the one page/script. The screen shot in the intro and this step are actually on the same web page. Each new command needs to be added in a few places in the PHP code/HTML, and also in the Arduino sketch, but the idea is that new commands will not be added very often. The page also has some macro commands to make it easier each year. Those can be added without changing the Arduino code.
On the Arduino side, the attached sketch connects to your Wifi network, loads the commands, and executes them in a loop. A hidden PHP page is used to retrieve the commands - it just returns the list, and does not remove them for this project since the main web page is where the command list is managed. You can run that hidden page on a browser to see if it is working.
The command format is simple - just a comma separated list of parameters.
The script only loads the commands once since we generally set the animation once per holiday and turn them on. It may not be worth the effort to load the commands repeatedly in the loop since you'd need to decide when to poll the server - each step of each animation, between steps, or with each loop. Changing the commands is mostly cool when you are showing off to neighbors :-) If you want to use a loop, the Xively CC3000 project linked from the Adafruit site has a repeating client example for the CC3000 shield.
We have a be nice policy.
Please be positive and constructive.