Good morning, can you give me a hand here? I'm trying to make the connection through the ethernet shield but it never lets me do the communication, does anyone know what it will be?
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 220 };
byte gateway[] = {192, 168, 1, 1};
byte subnet[] = {255, 255, 254, 0};
EthernetServer server(80);
const int ledPin = 9;
String readString = String(30);
int status = 0;
void setup(){
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop(){
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100)
{
readString += c;
}
if (c == '\n') {
if (readString.indexOf("?") <0){
}
else
if(readString.indexOf("ledParam=1") >0)
{
digitalWrite(ledPin, HIGH);
status = 1;
}else{
digitalWrite(ledPin, LOW);
status = 0;
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("");
client.println("");
client.println("MasterWalker Shop - Controlo de Leds via Web server");
client.println("");
client.println("");
client.println("
Braccio
");client.println("
CONTROlO DE LEDs
");if (status == 1){
client.println("");
}else{
client.println("");
}
client.println("Status atual do LED: ");
if (status == 1){
client.println("LIGADO");
}else{
client.println("DESLIGADO");
}
client.println("
");
client.println("
");
client.println("");
client.println("");
readString="";
client.stop();
}
}
}
}
}