Download the software for this guide from the following link:
Unzip the archive and you will find 2 Arduino sketches (one for the Yun, and the other for the CC3000), and a webpage directory.
If using the CC3000, adjust the defines at the top of the CC3000 sketch to configure it to access your wifi network:
python server.py
A simple web server should start hosting the control webpage. You can access this web page from http://localhost:5000/ on the server, or http://(your_server_IP_address):5000/ from another device on your network.
If you see an error that the Arduino IP address could not be found, this means the multicast DNS lookup failed to find the Arduino. Open server.py in a text editor and make sure the value of the ARDUINO_MDNS_NAME variable at the top matches the name assigned to your Arduino. On the Arduino Yun this value should be the name you assigned to the Yun in its configuration, with the '.local' suffix added--by default the Yun should use 'arduino.local'. On the CC3000, this value is 'arduino.local' by default (but can be changed in the setup function of the sketch).
If the Arduino MDNS name is correct and still cannot be resolved (for example if Bonjour is not installed on Windows) you can manually find the IP address of the Arduino (check your router's device list) and assign it to the ARDUINO_IP variable at the top of server.py. This will override the MDNS check with the IP value you provide. Note that the IP of your Arduino might change when it's restarted.
Once the server is running, access the web page from a browser and start controlling the lights!
Note: If you're using the Yun and have a password protecting the device you will need to enter the Yun's password in the dialog that pops up the first time you press a button on the control page (use username 'root' if prompted too).
Continue on to learn about enhancements you can make to this project.
Dependencies
Before going on you will need to install the following dependencies:- Adafruit NeoPixel library
- If using the CC3000:
- PIXEL_PIN: The digital output pin which is connected to the input of the NeoPixel strip.
- PIXEL_COUNT: The number of pixels in the NeoPixel strip.
If using the CC3000, adjust the defines at the top of the CC3000 sketch to configure it to access your wifi network:
- ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, ADAFRUIT_CC3000_CS: Set these to the appropriate pins which are connected to the IRQ, VBEN, and CS pins respectively on the CC3000.
- WLAN_SSID, WLAN_PASS, WLAN_SECURITY: Set these to the appropriate values for your wireless network.
Server
This project works by using a computer on your network to host a small control web page. The web page uses Javascript to call a simple REST API on the Arduino which controls the lights. To set up the server you will need to install the following software:- Python (this project has been tested with Python 2.x, but should work on 3.x)
- Flask (a simple python web framework)
- The easiest way to install flask is through pip, with the command pip install flask (on Mac OSX or Linux run with the sudo command as sudo pip install flask).
- Optionally on Windows, install Bonjour with the Bonjour Printer Services download. Bonjour's multicast DNS support is used to simplify configuration by automatically finding the IP address of the Arduino. If Bonjour is not available you can manually configure the Arduino IP address in the web page source.
python server.py
A simple web server should start hosting the control webpage. You can access this web page from http://localhost:5000/ on the server, or http://(your_server_IP_address):5000/ from another device on your network.
If you see an error that the Arduino IP address could not be found, this means the multicast DNS lookup failed to find the Arduino. Open server.py in a text editor and make sure the value of the ARDUINO_MDNS_NAME variable at the top matches the name assigned to your Arduino. On the Arduino Yun this value should be the name you assigned to the Yun in its configuration, with the '.local' suffix added--by default the Yun should use 'arduino.local'. On the CC3000, this value is 'arduino.local' by default (but can be changed in the setup function of the sketch).
If the Arduino MDNS name is correct and still cannot be resolved (for example if Bonjour is not installed on Windows) you can manually find the IP address of the Arduino (check your router's device list) and assign it to the ARDUINO_IP variable at the top of server.py. This will override the MDNS check with the IP value you provide. Note that the IP of your Arduino might change when it's restarted.
Once the server is running, access the web page from a browser and start controlling the lights!
Note: If you're using the Yun and have a password protecting the device you will need to enter the Yun's password in the dialog that pops up the first time you press a button on the control page (use username 'root' if prompted too).
Continue on to learn about enhancements you can make to this project.
Page last edited December 12, 2013
Text editor powered by tinymce.