Skip to content

Instantly share code, notes, and snippets.

@cieslak
Created November 19, 2012 18:45
Show Gist options
  • Save cieslak/4112791 to your computer and use it in GitHub Desktop.
Save cieslak/4112791 to your computer and use it in GitHub Desktop.
Arduino Web to LCD Service
You need:
- Arduino
- Ethernet Shield
- Sparkfun Serial LCD Kit
- Webduino library https://github.com/sirleech/Webduino
- Buzzer (optional)
Hook up:
- Ethernet shield to Arduino
- LCD: 5V and ground, serial to pin 3
- Buzzer: connect to pin 6 and ground
Change the MAC address var in the code to match your shield's MAC, and assign it a valid IP address for your network.
That's it.
#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"
#include "SoftwareSerial.h"
static uint8_t mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // change this to your Ethernet shield's MAC address
static uint8_t ip[] = { 192, 168, 1, 2 }; // change to your network
#define PREFIX ""
WebServer webserver(PREFIX, 80);
SoftwareSerial lcd(2,3);
void showForm(WebServer &server, WebServer::ConnectionType type, char *, bool) {
server.httpSuccess();
if (type != WebServer::HEAD) {
if (type == WebServer::POST) {
P(thxMsg) = "<!doctype HTML><html><body>Thanks!</body></html>";
server.printP(thxMsg);
bool repeat;
char name[16],value[32];
do {
repeat = server.readPOSTparam(name,16,value,32);
if (strcmp(name,"msg") == 0) {
lcd.write(0xFE);
lcd.write(0x01);
lcd.print(value);
tone(6,600,1000);
}
} while (repeat);
}
else {
P(formMsg) = "<!doctype HTML><html><body><form name=\"input\" action=\"/\" method=\"post\"><input type=\"text\" name=\"msg\"><input type=\"submit\" value=\"send\"></form></body></html>";
server.printP(formMsg);
}
}
}
void setup() {
Ethernet.begin(mac, ip);
lcd.begin(9600);
webserver.setDefaultCommand(&showForm);
webserver.begin();
}
void loop() {
char buf[64];
int len = 64;
webserver.processConnection(buf, &len);
}
@lingoslinger
Copy link

I modified this to work with the Parallax 16x2 backlit LCD display with piezo speaker here: https://gist.github.com/4385539. Hope this helps someone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment