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 12Talking to the stoplight

The web page presented by the stoplight is really only for testing.  If you want to tie the stoplight to real world events you will need script web calls to change the light on whatever trigger is desired.

To do this, you need to formulate web calls to the extremely lightweight "API" the light responds to.  In other words, you have to have your script craft a url that looks like an http GET request.

This url looks like:

http://<your stoplights name or IP>:<port>/b?<argument>&<argument>

The arguments are each separated by an & and should be one or more of these:

  • a= The "secret" password.  Not encrypted in any way, this is only to prevent casual browsers from resetting your light.  If this is not right the light will not change, it will just return a web page showing how it would have changed it, had the password been correct.  The password should not be any of the other words or subsets of them.  i.e. "yell" would be bad because it's a substring of "yellow"
  • c= One of: "red","yellow","green" or "beacon" to turn on the corresponding lamp or the auxiliary outlet. 
  • "error=1" to start the yellow light light blinking
  • "error=2" to start the red light blinking (We use this when we really want to call attention to something)
  • "error" (without a =1 or =2) to flash all three lights twice as fast as they flash when first powered on.
So, if your script needed to turn on the red and green lights, and your light is called "stoplight.example.com" you would have it make a call to "http://stoplight.example.com/b?a=secret&c=red&c=green".

Except in reality the server is just searching for certain keys words and ignores all the other characters.  So that example could also be "http://stoplight.example.com/bsecretredgreen" and work just as well.

We use it in conjunction with a server monitoring package.  Every five minutes during the day a script looks at the aggregate results of the things we care most about, and decides what state to set the stoplight to.  After hours, a single call turns all the lights off to save power.
« Previous StepDownload PDFView All StepsNext Step »
2 comments
Sep 28, 2011. 10:01 PMarduinopowered says:
Hi, im a small website server owner and i have built your project. Could you please possibly post an example script?
Sep 29, 2011. 2:02 AMarduinopowered says:
nervermind i worked it our, but for people who want to control it without a browser and dont know how heres is a basic html line you can add to control it

<.script GET src ="http://stoplight:port/bsecretredgreen"/>

is an example of turning red and green on

except get rid of the dot before script(its just so instructables doesnt treat it as a html line)

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?