Hello everybody I wanted my wifi robot to display a msg from my web controlling page.
So I'm using a 16x2 lcd with my ethernetshield and since i made a shiel for it taht uses the 11 and 12 pin i had to change them to 8 and 9 because ethernet shield uses 10..13.
I do have almost complete code but i can't get the lcd to display the msg i'll have to catch the msg from a GET response...
#include <WString.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
byte mac[] = { 0x00, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 2, 150 };
Server server(80);
String readString = String(30);
void setup(){
Serial.begin(9600);
Ethernet.begin(mac, ip);
lcd.begin(16, 2);
lcd.print("setup running");
}
void loop(){
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 30) {
readString.append(c);
}
if (c == '\n') {
if(readString.contains("msg")) {
lcd.clear();
// magic
// characters between:
// 'GET /?msg=' and 'HTTP/1.1'
// are important!
lcd.print("blabla");
}
// Now output HTML data starting with standart header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html><head><title>arduino ethernet msg board</title></head><body><center>");
client.println("<form method=get>");
client.println("<input type=text name=msg>");
client.println("<input type=submit value=send>");
client.println("</form>");
// debug
client.println(readString);
//
client.println("</center></body></html>");
readString="";
client.stop();
}
}
}
}
}
// EOF *******************************
simple hello msg
GET /?msg=hello HTTP/1.1
first 10 can be discarted (i don't know how)
and last 9 can be discarted
problem is the msg is not always the same length.
and i don't know how to manipulate a string.