now i have seen through the code, and searched around a bit, is this more correct code?
//*******************************
#include <SPI.h>
#include <Ethernet.h>
/*
Simple Ethernet Test
Arduino server outputs simple text to browser
and controlling LED with simple checkbox
The circuit:
* Arduino Duemilanove
* Arduino Ethernet shield
* Basic FTDI breakout 5V
* LED connected to GND and digital pin 4 via resistor
By Minde
http://www.sciencprog.com/
*/
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 110 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(80); // server port
byte sampledata=50; // some sample data – outputs 2 (ascii = 50 DEC)
int ledPin = 4; // LED pin
int heatpin = 5; // Heating *relay*
char link[]= ""; // link data
String readString = String(30); // string for fetching data from address
boolean LEDON = false; // LED status flag
boolean HEATON = false; // Heat status flag
void setup()
{
Serial.begin(57600); //enable serial datada print
Ethernet.begin(mac, ip, gateway, subnet); //start Ethernet
pinMode(ledPin, OUTPUT); //Set pin 4 to output
Serial.print("Starter server");
}
void loop(){
Client client = server.available(); // Create a client connection
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 30) { //read char by char HTTP request
readString.concat(c); } //store characters to string
Serial.print(c); //output chars to serial port for debugging
if (c == '\n') { //if HTTP request has ended
//lets check if LED should be lighted
if (readString.equalsIgnoreCase("L=1")) { //led has to be turned ON
digitalWrite(ledPin, HIGH); // set the LED on
LEDON = true;
}
if (readString.equalsIgnoreCase("L=0")) {
//led has to be turned OFF
digitalWrite(ledPin, LOW); // set the LED OFF
LEDON = false;
}
if (readString.equalsIgnoreCase("H=1")) { //heat has to be turned ON
digitalWrite(heatpin, HIGH); // set the heat on
HEATON = true;
}
if (readString.equalsIgnoreCase("H=0")) {
//heat has to be turned OFF
digitalWrite(heatpin, LOW); // set the heat OFF
HEATON = false;
}
client.println("HTTP/1.1 200 OK"); // now output HTML data starting with standart header
client.println("Content-Type: text/html");
client.println();
client.print ("<body style=background-color:white>"); //set background to white
// HTML Code
client.println("<font color='red'><h1>Arduino fjernstyringsside</font></h1>");//send first heading
client.println("<hr />");
client.println("<font color='blue' size='5[ch8242]>Sample data: "); //output some sample data to browser
client.print(sampledata);//lets output some data
client.println("
");//some space between lines
client.println("<hr />");
client.println("<font color='green'>Simple table: "); //drawing simple table
client.println("
");
client.println("<table border=1><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr>");
client.println("<tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table>");
client.println("
");
client.println("<hr />");
client.println("<font color='blue' size='5[ch8242]>Link: "); //printing some link
client.print("<a href=");
client.print(link);
client.println(">Visit Scienceprog!</a>");
client.println("
");
client.println("<hr />");
//controlling led via checkbox
client.println("<h1>LED control</h1>");
//address will look like http://192.168.1.110/?L=1 when submited
client.println("<form method=get name=LED> <input type='radio' name='L' value='1'>LED ON
<input type='radio' name='L' value='0'>LED OFF
<input type='radio' name='H' value='1'>HEAT ON
<input type='radio' name='H' value='0'>HEAT OFF
<input type=submit value=submit></form>");
client.println("
");
//printing LED status
client.print("<font size='5[ch8242]>LED status: ");
if (LEDON) {
client.println("<font color='green' size='5[ch8242]>ON");
}
else {
client.println("<font color='grey' size='5[ch8242]>OFF");
}
client.println("<hr />");
client.println("<hr />");
client.println("</body></html>");
//clearing string for next read
readString="";
//stopping client
client.stop();
Serial.println("Stopper klient");
}}}}}
still a bit confused...
(i'm still a real newbie)