Few days back I started a project to interface ardunio with the ENC28J60 Ethernet shield. I am totally new to the world of electronics and i got the code for controlling an LED and reading an analog input from a website. And everything wen't well and now I'm able to control the led through a webpage and the webpage is showing the analog reading on the webpage beautifully. But as you might have guessed, I'm able to control the arduino board and the associated sensors though the cross-over Ethernet cable. Now I wanna extend this project and control the LEDs through internet, so that I can access it from anywhere with a valid internet connection. Now coming to the ACTUAL DOUBT, here it does. 1. I need an Internet source to connect to my ENC28J60 board. Can I provide this source using the following setup? I'll connect a USB dongle to my laptop and I'll share the internet connection from my laptop to the LAN. And if I can do that what should be the IP address to enter into the browser to access the webpage written in my arduino board? If this does not work in what way can I provide my internet source to my ENC28J60 so that I'll be able to access it globally through browsers?
// A simple web server that always just says "Hello World"
#include "etherShield.h"
#include "ETHER_28J60.h"
int outputPin = 6;
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24};
// so unless you have more than one of these boards
// connected, you should be fine with this value.
static uint8_t ip[4] = {169, 254, 2, 233}; // the IP address for your board. Check your home hub
// to find an IP address not in use and pick that
// this or 10.0.0.15 are likely formats for an address
// that will work.
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 e;
void setup()
{
e.setup(mac, ip, port);
pinMode(outputPin, OUTPUT);
}
void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("<H1>Web Remote</H1>");
e.print("<A HREF='?cmd=off'>Turn off</A>");
e.print("<H1> </H1>");
e.print("<A HREF='?cmd=on'>Turn on</A>");
if (strcmp(params, "?cmd=on") == 0)
{
digitalWrite(outputPin, HIGH);
}
else if (strcmp(params, "?cmd=off") == 0) // Modified -- 2011 12 15 # Ben Schueler
{
digitalWrite(outputPin, LOW);
}
e.print("<H1>Analog Value</H1><br/><table>");
e.print("<tr><th>Inputpin</th><td><td><td><td><th>Value</th></tr>");
e.print("<tr><td>"); e.print(0); e.print("</td><td><td><td><td><td>"); e.print(analogRead(0)); e.print("</td></tr>");
e.respond();
}
delay(100);
}