Hi
I have post the code below, When I use port 80 I can access and control my Arduino over the local network using IP 192.168.1.20. When trying to control it from the outside (31...***/80) world using mobile and a friend tried using laptop the page will open up but no control.
I change the port to 50, 81, 8080, 888 and lastly 1723 but I then lose the ability to see it on my local network and outside world. Here is the code.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192,168,1,20);
IPAddress gateway(192,168,1,254);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server(80);
int led = 5;
void setup() { pinMode(led, OUTPUT);
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
Serial.println("Server address:");
}
void loop() {
EthernetClient client = server.available();
if (client){
Serial.println("Got a client");
boolean currentLineIsBlank = true;
String buffer = "";
while (client.connected()){
if (client.available()) {
char c = client.read();
buffer+=c;
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("
Led Control
");
client.print("
");
client.print("
");
client.print("");
break;
}
if (c == '\n') {
currentLineIsBlank = true;
buffer="";
}
else
if (c == '\r') {
if(buffer.indexOf("GET /?status=Turn+ON")>=0)
digitalWrite(led, HIGH);
if(buffer.indexOf("GET /?status=Turn+OFF")>=0)
digitalWrite(led, LOW);
}
else {
currentLineIsBlank = false;
}
}
}
client.stop();
}
}
***************************************************
Thanks for the help.