coloquei este código aqui na integra:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 43 }; // ip in lan
//subnet mask
EthernetServer server(80); //server port
byte sampledata=50; //some sample data - outputs 2 (ascii = 50 DEC)
int ledPin1 = 2; // LED pin 1
String readString = String(30); //string for fetching data from address
boolean LEDON1 = false; //LED status flag
void setup(){
//start Ethernet
Ethernet.begin(mac, ip);
//Set pin 4 to output
pinMode(ledPin1, OUTPUT);
//enable serial datada print
Serial.begin(9600);
}
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() < 30)
{
//store characters to string
//-----readString.append(c);
readString.concat(c);
}
//output chars to serial port
Serial.print(c);
//if HTTP request has ended
if (c == '\n') {
//lets check if LED should be lighted
//------------LED 1
if (readString.substring(6,11) == "L1=ON")
{
digitalWrite(ledPin1, HIGH); // set the LED on
LEDON1 = true;
}
else if (readString.substring(6,12) == "L1=OFF")
{
digitalWrite(ledPin1, LOW); // set the LED OFF
LEDON1 = false;
}
// now output HTML data starting with standart header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
//set background to yellow
client.print("<body style=background-color:yellow>");
client.println("<h1>LED control</h1>");
client.println("<font color='black'>");
client.println("
");
//--------LED 1 CONTROLL--------
client.println("<form method=get name=LED><input type=submit name=L1 value=ON> LED 1<form>");
client.println("<form method=get name= LED><input type=submit name=L1 value=OFF ><form>");
if (LEDON1)
{
client.print("<font color='green' size='3'> ON");
}
else
{
client.print("<font color='red' size = '3'> OFF");
}
client.println("<font color='black'
");
client.println("</body></html>");
//clearing string for next read
readString="";
//stopping client
client.stop();
}
}
}
}
}
Funcionou perfeitamente, pagina em amarelo com boão liga e desliga.... porém quando eu copio a parte:
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
//set background to yellow
client.print("<body style=background-color:yellow>");
client.println("<h1>LED control</h1>");
client.println("<font color='black'>");
client.println("
");
ele sai tudo escrito na página