Per a request, I am posting a very simple script that looks for only one text box and sets an LED on Pin 9 to the brightness. This script does NOT use BlinkM I only used that script as a starter for this one.
// Based on
// Small Arduino Webserver --- for BlinkM
// Modified for single text box for brightness
// Jun 7 2012 - Mike Audleman
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#define maxLength 25
byte mac[] = {
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
String inString = String(maxLength);
char colorBuff[4];
int val;
EthernetServer server(80);
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac);
server.begin();
}
void loop()
{
int bufLength;
EthernetClient client = server.available();
if (client) {
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (inString.length() < maxLength) {
inString += c;
}
if (c == '\n' && current_line_is_blank) {
if (inString.indexOf("?") > -1) {
int Pos_L = inString.indexOf("L");
int End = inString.indexOf("H", Pos_L);
if(End < 0){
End = inString.length() + 1;
}
bufLength = ((Pos_L) - (Pos_L+2));
if(bufLength > 4){ //dont overflow the buffer
bufLength = 4;
}
inString.substring((Pos_L+2), (End-1)).toCharArray(colorBuff, bufLength); //transfer substring to buffer
val = atoi(colorBuff);
Serial.print("LED = ");
Serial.println( val );
analogWrite(9, val);
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html><head></head><body>");
client.println("<h1>LED - enter values 0 to 255</h1>");
client.print("<form method=get>LED:<input type=text size=3 name=L value=");
client.print(val);
client.print("> <input name=H type=submit value=submit></form>");
client.println("</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();
}
}