Doesn't Arduino 1.0 require: Ethernet.begin(mac, ip, DNS_SERVER, gateway, subnet); ?
I tested the code before I posted it and it worked, but YMMV for your setup. I would followup more on this, but my laptop has developed overheating issues that make posting very difficult.
system
May 23, 2012, 5:10pm
22
Hi, I have the "
ENC28J60 Ethernet. "As it is for
read and write from the processing?
here is a working example showing 3 text boxes for RGB values, when submitted it sets the pwm values of pins 3,5 & 6
This code works on wiznet shield and compiled with IDE_0018, yes its 0018 don't mention Arduino 1.0, if it aint broke why fix it
#include <Ethernet.h>
#include <WString.h>
#include <Wire.h>
#define maxLength 25
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 2, 20 };
String inString = String(maxLength);
int val;
int r;
int g;
int b;
Server server(80);
void setup()
{
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
}
void loop()
{
Client client = server.available();
if (client) {
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.print(c);
if (inString.length() < maxLength) {
inString.append(c);
}
if (c == '\n' && current_line_is_blank) {
if (inString.contains("?")) {
int Pos_r = inString.indexOf("r");
int Pos_g = inString.indexOf("g");
int Pos_b = inString.indexOf("b");
int End = inString.indexOf("H");
r = atoi(inString.substring((Pos_r+2), (Pos_g-1)));
g = atoi(inString.substring((Pos_g+2), (Pos_b-1)));
b = atoi(inString.substring((Pos_b+2), (End-1)));
analogWrite(6, r);
analogWrite(5, g);
analogWrite(3, b);
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html><head></head><body>");
client.println("<h1><CENTER>Aduino & Ethershield Webserver</CENTER></h1>");
client.println("<CENTER><form method=get>R:<input type=text size=3 name=r>G:<input type=text size=3 name=g>B:<input type=text size=3 name=b> <input type=submit value=submit></form></CENTER></body></html>");
break;
}
if (c == '\n') {
current_line_is_blank = true;
} else if (c != '\r') {
current_line_is_blank = false;
}
}
}
delay(1);
inString = "";
client.stop();
}
}
kindly upload your arduino and HTML code.