3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Arduino stoplight web server

Step 2Program Arduino and set up ethernet shield

This step can obviously be done later, but if you have the arduino set up as a web server with the control code first, you will be able to test your relay circuit as soon as it is ready. 

You can extract the arduino sketch from the attached "stoplight.zip" file or Download the latest version from http://code.google.com/p/stopduino/.  Open the stoplight.pde file in the arduino IDE and make the following changes before uploading to your arduino:
  1. Because the stoplight will serve as a server and needs to have a non-changing IP address, the IP address is hard coded in the sketch.  You will want to change the line that says "byte ip[] = { 192, 168, 119, 177 }; " to match the IP address you want to assign the stoplight.  Note that the quads that make up the IP address are separated by commas not dots.  This is because the IP address is stored as an array of 4 bytes, each of which is one of the bytes of the IP address.
  2. Do the same thing for the "byte mac[] " line, substituting the MAC address of your ethernet shield.  It should be printed on it somewhere.
  3. Change the "char secret[] " array to be whatever password you want to use.
  4. Change the number in the "EthernetServer server(####) " line to be whatever port you want the server to listen on.  Normally this would port 80.
Program the arduino with your modified sketch, attach the ethernet shield to the arduino, plug it into your network, and then open up a browser window to http://<IP you put in>:<port you put in> or just http://<IP you put in> if you chose port 80 as the port.

Ideally, you should have DNS set up for the stoplight server IP, so you can refer to it as something like http://stoplight.example.com but IP addresses work just as well.

After connecting you should see a simple web page that shows you the current status of each of the lights, complete with check boxes and a place to put your password to change each of them.

If you see the web page appear at all, you will know that your ethernet shield is working, and your arduino is now a web server, even if you can't see it affecting the outside world yet.

Watching the check boxes change without seeing the arduino do anything is pretty boring, so see the next step for an optional test rig you can build for instant (or at least sooner) gratification.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
18
Followers
5
Author:mkanoap
He's just this guy, you know?