Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- #include <LiquidCrystal.h>
- #include <SD.h>
- byte mac[] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
- byte ip[] = { 192, 168, 0, 31};
- File myFile;
- char current_char;
- Server server(80);
- LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
- void setup()
- {
- Serial.begin(9600);
- pinMode(10, OUTPUT);
- lcd.begin(16, 2);
- Ethernet.begin(mac, ip);
- delay(1000);
- server.begin();
- Client client = server.available();
- myFile = SD.open("index.html");
- if (myFile) {
- while (myFile.available()) {
- Serial.println(myfile.read());
- client.write(myFile.read());
- }
- }
- Serial.println("setup finished");
- }
- void loop()
- {
- String buffer = "";
- String requesturl = "";
- String buffers = "";
- Client client = server.available();
- if (client) {
- boolean currentLineIsBlank = true;
- while (client.connected()) {
- while(client.available()) {
- char c = client.read();
- if(requesturl == ""){
- buffer += c;
- if(c == '\n' && buffer.startsWith("GET")){
- requesturl = buffer.substring(12,buffer.length()-11);
- buffer = "";
- requesturl.replace('+',' ');
- requesturl.replace('%3F','?');
- requesturl.replace('%21','!');
- lcd.clear();
- if (requesturl.length() > 16){
- lcd.print(requesturl.substring(0,16));
- lcd.setCursor(0,1);
- lcd.print(requesturl.substring(16,requesturl.length()));
- }else{
- lcd.setCursor(0,0);
- lcd.print(requesturl);
- }
- }
- }
- if (c == '\n' && currentLineIsBlank) {
- } else if (c == '\n') {
- currentLineIsBlank = true;
- }
- else if (c != '\r') {
- currentLineIsBlank = false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement