Need some general help on ethernet shiled wiring and Server control.

I'm having a heck of a time figuring out how to control a simple led on/off through any type of web server through ethernet to my Uno. I need help from the ground up. I've tried other posts and youtube. I do not know the a thing about servers or PHP so I'm stuck. Once someone gets me started with a simple plan I can take it and run. After I get the communication up and running I want to use ethernet+Xbee+Uno to crontrol a bot.

Thanks in advance.

If what you describe in your post is all you want to achieve, you should first try google before posting. I entered "arduino led on off webserver" in the google search field and the first two items were examples of what you describe, one of them even in the Arduino playground. If these projects doesn't satisfy your needs, describe them in a bit more detail.

I have found lots of examples, but have no idea to do any of the ports or HTML stuff. I'm trying to teach myself about all of this, but I seem to be missing a step. I eventually want to control a robotic arduino through the ethernet to one arduino+Xbee to a wireless Arduino+Xbee. Any help?? If I could get the web server part up and running I think I could change it enough to do the deed.

If I could get the web server part up and running I think I could change it enough to do the deed.

Are you trying to set up a web server and have the Arduino act as a client, accessing your server? Or, are you trying to have the Arduino act as server?

Forget about your long-term goal for the moment. There are client and server examples provided with the Ethernet library. Have you successfully executed them?

I have not. Give me a good one to try and I'll shoot for the stars. I have plenty of time and Internet. I also have a knock off ethernet shield that needs to be explained. It's a HanRun?

I have not.

You have not what? Tried to set up a web server on the PC? Tried the client code on the Arduino? Tried the server code on the Arduino?

As Foghorn Leghorn says, "Pay attention, boy!".

I have now tried all the above. I do not know how the HTML communicates with the PHP code. The php code is the one that talks to the Arduino correct?
I could make this very simple and say I need held by the hand with step by step instructions on how to do this. With out the assumption that I know a thing. I can handle the Arduino and the Xbee. I cannot handle the ethernet part. I have tinkered with this for about a week and just now got the ethernet wired up, I think. I don't have the slightest idea how the Arduino acts as a server or client. I don't know where to go online to check if my work is any good. I know nothing. Hint the login name. =( =( =( =( =( Any help will be appreciated. I will even take the sarcasm with a grain of salt, as long as someone is helping.

I'm new to hardware and Arduino, but here's how I would proceed. As Paul mentioned, you should start off slow. You should start with the very basics and build things in small parts.

I'm assuming you have no Arduino experience at all.

To get familiar with the Arduino and uploading sketches, I would start with the blink tutorial. It is located here: http://arduino.cc/en/Tutorial/Blink

That will give you the basics of how sketch works. I would suggest trying this exercise using the built in led. Then I would try it using an led and breadboard.

This will give you the basics of turning an led on and off. There is a problem with this sketch though since there is a delay that blocks the loop.

Next I would do the BlinkWithoutDelay tutorial: http://arduino.cc/en/Tutorial/BlinkWithoutDelay

This shows you how to do a blink without blocking your loop.

Next I would do the AnalogInOutSerial tutorial: http://arduino.cc/en/Tutorial/AnalogInOutSerial

This gives you some basics on how to control the brightness of an led, but it also shows you how to use the Serial console.

The serial console is useful for debugging.

Now if you're comfortable with the code and how everything works in 1-3, I would try the WebClient tutorial

This shows you how to send a query to Google and read a response.

You will need to know how to do this for your project I think.

I would go through the rest of the Ethernet Library tutorials until you understand how they work:

They are listed at this link - http://arduino.cc/en/Tutorial/HomePage

See the ones under "Ethernet Library"


As for using HTML and PHP, I'm not sure that would be the best way to control a robot.

I guess it could work if you made the Arduino/Ethernet board act as the server. It wouldn't work well if the Arduino was the client.

If you're going to use an XBee, why do you need the Ethernet?

Also I would look into using UDP instead of HTTP. I think it will be simpler to parse.

See this example: http://arduino.cc/en/Tutorial/UDPSendReceiveString

Once you get that example to work, try to modify it so you can control leds instead.

This is what the example does:

If you press a key, then a Hello World message will be sent to the Arduino and you can view it in the Serial monitor. After the Arduino will send a reply to the sender.


Now for your LED prototype, you'd need to modify the code so that it sends different messages. Preferably just a single character. 1 or 0 for example.

So now if you press 1, the Arduino will get that message. In your Arduino sketch, make it so you the LED turns on when it receives a 1. If a 0 is received, turn off the LED.

I have done the simple codes and wrote a few of my own. I'm writing and building one for the bot now. The Ethernet is so I can control the Arduino from my house to my parents and the Xbee is to control the bot from there. A lot of work, but a fun project that I hope to turn into something useful. Just need the communication from my computer to ethernet through the net. No luck yet.

simple server control code.

//zoomkat 4-1-12
//simple button GET for servo and 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, or use ' instead of " 
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

#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
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  myservo.write(90); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("server servo/pin 5 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; 
          //Serial.print(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();

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

          client.println("<H1>Zoomkat's simple Arduino button</H1>");
          
          client.println("<a href=\"/?on\">ON</a>"); 
          client.println("<a href=\"/?off\">OFF</a>"); 

          client.println("</BODY>");
          client.println("</HTML>");
 
          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on") >0)//checks for on
          {
            myservo.write(40);
            digitalWrite(5, HIGH);    // set pin 5 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            myservo.write(140);
            digitalWrite(5, LOW);    // set pin 5 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

OK. I have now tried several of the ethernet libraries and none worked. I have a cheap ethernet Shield from eBay. It has 10 pins.
CLKOUT|INT
WOL |SO
SI |SCK
CS |RESET
VCC |GND
I have it as followed to my UNO.
INT #3
SO #12
SI #11 SCK #13
CS #10
VCC 3.3v GND GND

Any corrections? Maybe its my IP addressing? Little help would be great. I can load and work just about all other codes. Just can't do this Ethernet crap.

I have a cheap ethernet Shield from eBay.

Really? That one?

I have a cheap ethernet Shield from eBay.

Bummer

Well when I bought my stuff, I had no intention on using ethernet until I realized what an Arduino is capable of. So yes I bought a bunch of cheap parts offline all in one fast swoop. This is the first time any of it gave me trouble. So I'll order a GOOD one I suppose and then maybe I'll get some real help instead of telling me to keep trying the same crap I have been doing. Thanks for a whole lot of nothing. Youtube has more useful knowledge then this.

Nobody told you that you have bought crap but if you just talk about an Ethernet Shield everybody here assumes the original one. If you use another one, you have to include a link to the one you're using. If you bought one without having a documentation to it (as it is often the case with the cheapest on ebay), you cannot expect us to know what you have and how it's used. Then you're really left alone, measuring and trying till you find out how it works.

Seems to me guys just like to comment on every post with nothing helpful, just to get there name in it. If they are interested in helping then they would give me some trouble shooting tips. Not refer to playground or sketch's. I have tried all the sketch's and googled and possible ways to wire it up. I'm stuck and don't know what the problem is. Instead of just saying oh that one, maybe some advice on if I have my connections right and if an extra code is needed. Now that it's not simple as just referring me to the already written codes they have nothing to say. So now what needs done to make it work?

Thanks for a whole lot of nothing.

That's a good summary of what you have described about what you ACTUALLY tried/bought/knew.

Seems to me guys just like to comment on every post with nothing helpful, just to get there name in it.

If you're always so nice to the guys trying to help, you cannot be surprised if you seldom get help. Don't forget the people on the forum are doing their "job" voluntarily, they don't get a penny for it.

So now what needs done to make it work?

You haven't supplied us with technical data about the shield you're using. You haven't posted a picture of your setup (given that your ebay supplier didn't give you anything like a documentation), allowing us to check the wiring and maybe identifying your hardware. You haven't followed the tips given in the thread (p.e. from gohn67). You just complained about us not helping you.
If you don't supply the information we cannot help you.

NewGuyW_Oexperience:
Well when I bought my stuff, I had no intention on using ethernet until I realized what an Arduino is capable of. So yes I bought a bunch of cheap parts offline all in one fast swoop. This is the first time any of it gave me trouble. So I'll order a GOOD one I suppose and then maybe I'll get some real help instead of telling me to keep trying the same crap I have been doing. Thanks for a whole lot of nothing. Youtube has more useful knowledge then this.

Perhaps you have a ENC28J60 based ethernet shield. You can search the forum forum for ENC28J60 to see what others have posted in the past. This board requires somewhat advanced programming skills. One can get a w5100 based ethernet shield shipped to the US for $10 (below).

http://www.ebay.com/itm/Ethernet-Shield-W5100-For-Arduino-2009-UNO-Mega-1280-2560-/270955738702?pt=LH_DefaultDomain_0&hash=item3f1638764e