Created
November 19, 2012 18:45
-
-
Save cieslak/4112791 to your computer and use it in GitHub Desktop.
Arduino Web to LCD Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!