public
Created

Simple Arduino Webserver With Hits/IP on LCD & DHCP

  • Download Gist
PonyWeb.pde
Processing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#include <Wire.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>
 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE };
 
EthernetServer server(80);
 
LiquidCrystal lcd(0);
 
int hits = 0;
 
void setup(){
lcd.begin(16, 2);
lcd.print("PonyDuino!");
lcd.setCursor(0, 1);
lcd.print("hits:");
Ethernet.begin(mac);
lcd.setCursor(0,0);
lcd.print(Ethernet.localIP());
server.begin();
}
 
void loop(){
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<h1>Hai. I am Lance's Arduino! <3</h1>");
client.print("<h2>I can has analog portz:</h2>");
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(analogRead(analogChannel));
client.println("<br />");
}
client.print("<h2>And here is a pretty pony!</h2>");
client.print("<img src='http://powet.tv/powetblog/wp-content/uploads/2011/02/my_little_pony_friendship_is_magic_rarity.jpeg' />");
hits = ++hits;
lcd.setCursor(6,5);
lcd.print(hits);
break;
}
}
client.stop();
}
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.