What is the URL of my buttons?

Hi, I have Uno R3, W5100 ethernetshield and IDE 1.0.1. I created a webserverpage with some buttons that executes some code in my program. The buttons works fine, but I also want to start these functions through an URL. I thought this was the URL, but that does not work. Can anyone give me a hint? Below are some parts of my code.

void toggleLightCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
  if (type == WebServer::POST)
    bool repeat;
    char name[16], value[16];
      repeat = server.readPOSTparam(name, 16, value, 16);

      if (strcmp(name, "command") == 0)
      else if (strcmp(name, "setup") == 0)
    while (repeat);
  server.httpSuccess();/* for a GET or HEAD, send the standard "it's all OK headers" */
  if (type == WebServer::GET){  /* we don't output the body for a HEAD request */
    P(message) = 
      "<body><form action='/' method='POST'>ELRO
      "A<button class='positive' name='command' value='aOn'>Aan</button> <button class='negative' name='command' value='aOff'>Uit</button>
      "B<button class='positive' name='command' value='bOn'>Aan</button> <button class='negative' name='command' value='bOff'>Uit</button>
      "C<button class='positive' name='command' value='cOn'>Aan</button> <button class='negative' name='command' value='cOff'>Uit</button>
      "D<button class='positive' name='command' value='dOn'>Aan</button> <button class='negative' name='command' value='dOff'>Uit</button><HR>"
1<button class='positive' name='command' value='eOn'>Aan</button> <button class='negative' name='command' value='eOff'>Uit</button>
      "2<button class='positive' name='command' value='fOn'>Aan</button> <button class='negative' name='command' value='fOff'>Uit</button><hr>"
<button class='positive' name='command' value='AllOn'>Aan</button> <button class='negative' name='command' value='AllOff'>Uit</button><hr>"
<button class='positive' name='command' value='Garage'>Aan</button>"
      "<hr><button class='neutral' name='setup' value='setup'>Learn</button>"

"But that does not work" is too lame for us to provide any help. You'll have to do better than that.

Something happens. You have to tell us what.

It would be far simpler to parse the URL if each of your buttons had its own name. Did your parents name you and all of your siblings the same thing? I doubt it.

Ok when I type in the browser I get the message EPIC FAIL in the browser window. Still pretty lame? Please keep my parent out of this conversation. I appreciate people that actually help.

Not being an American, you probably never saw "The Bob Newhart Show". There was a main character on that show named Darryl. He had two brother - "my brother Darryl" and "my other brother Darryl". It was an endless source of confusion as to which Darryl was being referred to.

You have 4 buttons named command. That is no different from 3 brothers named Darryl.

in the browser I get the message EPIC FAIL in the browser window. Still pretty lame?

Yes, I'm afraid so. When a browser attempts to fetch a URL, there are standard error codes associated with the success or failure of the GET command that is at the root of the process. For a browser to treat all failures the same way ("EPIC FAIL") instead of telling you exactly why the GET failed (404 - URL not found, 503 - invalid access, etc.) is pretty lame.

I'd recommend trying a different browser. Of course, you need to make sure that the IP address in the URL is correct. That is done with no arguments.

Turning on Serial output on the Arduino, and opening the Serial Monitor will tell you whether a connection to the Arduino is even happening, and, if so, what the Arduino received and what it generated/sent as a result.

When I type in my browser I get the webpage with buttons that I expected. Please see the webserver GET code above how the webserver outputs HTML to my browser. The webserver POST code searches for "command" in the name field and is able to pass value "aOn" or "aOff" to the function switchLights(value). I hoped that would do the same but I only see the EPIC FAIL message that the webduino webserver outputted. Does anyone have an idea what is the URL of my buttons? Clearly I don't understand yet how to pass parameters through the URL.

Suggest you make sure your sketch prints out trace information each time it receives an HTTP request so that you can see (a) that there is an incoming connection (b) what HTTP request was received (c) what the response was.

I don't know what browser you're using but it's not impossible that the behaviour you're seeing is the result of browser caching rather than a response sent from the Arduino. The trace output would make it clear whether this was the case. Also print out the Arduino's IP address at startup, in case this is changing.

I haven\t done any of this programming on arduino but when I look at the code the problem I think you have is that when you type the exact URL for a button in the web browser the web browser (as it should) sends a HTTP GET message. The buttons on the page makes the browser send a HTTP POST message (as it should). The code for switching the light is only run when a HTTP POST message is received.

If you don't understand this about GET and POST I suggest you google for some HTTP protocol description. And if you do, see if the code for the GET message can retrieve the same parameters as in the POST message. So if there are no parameters in the URL it displays the page, if there is any (valid) parameters it executes the requested function.

Aqualize, thanks for your useful reply. I read a bit about GET and POST. My HTML page uses POST and then the parameters are not not found in the URL but in the message body. If I want to send parameters through URL then I must use GET. In the HTML I changed the method from POST to GET and then I saw the URL, that's what I am looking for. Next step is to handle the GET request in the code in my Arduino. Thanks again.

Next step is to handle the GET request in the code in my Arduino.

I still think that giving each button a different name is going to make your job easier.

Simple button test code that prints what the browser sends to the serial monitor.

//zoomkat 3-17-12
//simple button GET server code to control servo and arduino pin 5
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html 
//address will look like when submited
//for use with W5100 based ethernet shields
//Powering a servo from the arduino usually DOES NOT WORK.
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605 

#include <SPI.h>
#include <Ethernet.h>

//#include <Servo.h> 
//Servo myservo;  // create servo object to control a servo 

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 
  192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 


void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  pinMode(6, OUTPUT); //pin selected to control
  pinMode(7, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);

  //enable serial data print 
  Serial.println("server LED test 1.0"); // so I can keep track of what is loaded

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 

        //if HTTP request has ended
        if (c == '\n') {

          Serial.println(readString); //print to serial monitor for debuging 

            client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");

          client.println("<TITLE>Arduino GET test page</TITLE>");

          client.println("<H1>Zoomkat's simple Arduino button</H1>");

          // DIY buttons
          client.println("<a href=\"/?on1\"\">ON</a>"); 
          client.println("<a href=\"/?off1\"\">OFF</a>

          // mousedown buttons
<input type=\"button\" value=\"ON\" onmousedown=\"location.href ('/?on2');\"/>"); 
          client.println("<input type=\"button\" value=\"OFF\" onmousedown=\"location.href ('/?off2');\"/>");        

          // mousedown radio buttons

<input type=\"radio\" value=\"ON\" onmousedown=\"location.href ('/?on3');\"\">ON</>"); 
          client.println("<input type=\"radio\" value=\"OFF\" onmousedown=\"location.href ('/?off3');\"\">OFF</>");        


          //stopping client

          ///////////////////// control arduino pin
          if(readString.indexOf("on1") >0) {
            digitalWrite(5, HIGH);
            Serial.println("Led on1");
          if(readString.indexOf("off1") >0) {
            digitalWrite(5, LOW);
            Serial.println("Led off1");

          if(readString.indexOf("on2") >0) {
            digitalWrite(6, HIGH);
            Serial.println("Led on2");
          if(readString.indexOf("off2") >0) {
            digitalWrite(6, LOW);
            Serial.println("Led off2");

          if(readString.indexOf("on3") >0) {
            digitalWrite(7, HIGH);
            Serial.println("Led on3");
          if(readString.indexOf("off3") >0) {
            digitalWrite(7, LOW);
            Serial.println("Led off3");
          //clearing string for next read

Hi jrsikken,

Just waking up with my first café, so if I misunderstand, I apologise.

Firstly, without seeing all your code, it appears to me that you may be using the WebDuino library, is this correct? Secondly, you are issuing a http GET by supplying the data in your URL line, but looking at your code you have on the third line down the following;

if (type == WebServer::POST)

Is this not then wanting to see a http POST structure?

If so, I think the Webduino library is then defaulting to give you the lovely 'Epic Fail'.

If your code is in one file, it might be worth your while to show it all.

Tot ziens, Paul

Thanks all for your replies. I nolonger need to find the URL with the same parameters as my http POST message. I figured out how to read the paremeters from a http POST. Thanks anyway!