Ethernet shield questions?


so got arduino ethernet shield.  i've been playing arduino couple of years , i'm pretty handy c , c++.  don't know networking, internet protocols, html, , sort of thing.  wondering if point me towards example projects can @ , learn from.  i've done searching, i'm having little trouble telling wheat chaff. 

all projects have done before involved communicating computer involved serial communications program on computer.  new project far away of computers, close router thought great time learn communicate on net.

basically, want have simple web interface allows me change parameters on arduino.  write code via serial in sleep, wouldn't learn how via web.  i'm not interested in being able access over, inside home network.  possible?  way can hide behind router , won't need security? 



a second question:

i have commercially made controller handles timers , such aquarium.  has web interface allows control anywhere internet connection.  accepts telnet commands , have discovered extended command set can use via telnet computer.  able exploit , have arduino control controller polling , sending commands telnet? 

simple server test code controlling things.

code: [select]

//zoomkat 4-1-12
//simple button servo , pin 5
//for use ide 1.0
//open serial monitor see arduino receives
//use \ slash escape " in html, or use ' instead of "
//address http://192.168.1.102:84 when submited
//for use w5100 based ethernet shields

#include <spi.h>
#include <ethernet.h>

#include <servo.h>
servo myservo;  // create servo object control 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 control
  //start ethernet
  ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  myservo.write(90); //set initial servo position if desired
  myservo.attach(7);  //the pin servo control
  //enable serial data print
  serial.begin(9600);
  serial.println("server servo/pin 5 test 1.0"); // can keep track of loaded
}

void loop(){
  // create client connection
  ethernetclient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char char http request
        if (readstring.length() < 100) {

          //store characters string
          readstring += c;
          //serial.print(c);
        }

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

          ///////////////
          serial.println(readstring); //print serial monitor 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 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 on
          {
            myservo.write(40);
            digitalwrite(5, high);    // set pin 4 high
            serial.println("led on");
          }
          if(readstring.indexof("off") >0)//checks off
          {
            myservo.write(140);
            digitalwrite(5, low);    // set pin 4 low
            serial.println("led off");
          }
          //clearing string next read
          readstring="";

        }
      }
    }
  }
}



Arduino Forum > Using Arduino > Project Guidance > Ethernet shield questions?


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial