using the Ethernet shield and the webduino library, I am having alot of trouble figuring out how to get data from a web form back to the arduino.
I have modified the demo code to include 2 new forms as follows:
for (i = 0; i <= 9; ++i)
{
// ignore the pins we use to talk to the Ethernet chip
int val = digitalRead(i);
server << "Digital " << i << ": ";
if (addControls)
{
char pinName[4];
pinName[0] = 'd';
itoa(i, pinName + 1, 10);
server.radioButton(pinName, "1", "On", val);
server << " ";
server.radioButton(pinName, "0", "Off", !val);
server.println("
");
if (i == 5){
server.println(slider = "");
server.println("
");
server.print(" First name: ");
server.print("
");
server.println("
");
}
}
else
server << (val ? "HIGH" : "LOW");
server << "
";
}
now how can I get this data back to the arduino as variables?!!?!?! :* so frusterating!!
I'm guessing it involves using the following part of the code:
void formCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
if (type == WebServer::POST)
{
bool repeat;
char name[16], value[16];
do
{
repeat = server.readPOSTparam(name, 16, value, 16);
// Serial.println("mexicans");
//Serial.println(repeat);
//Serial.println("test2");
if (name[0] == 'd')
{
int pin = strtoul(name + 1, NULL, 10);
int val = strtoul(value, NULL, 10);
digitalWrite(pin, val);
// Serial.println("mexicans");
//Serial.println(server.readPOSTparam(name, 16, value, 16));
//Serial.println("rad");
}
} while (repeat);
server.httpSeeOther(PREFIX "/form");
}
else
outputPins(server, type, true);
}
:~