Salve a tutti!
Premetto di avere un arduino uno e ethernet shield che mi consente di utlizzare la schedina sd come memoria esterna dove andar a prendere dei file.
detto questo vorrei sapere quale codice devo immetere nel mio sketch per poter utilizzare il mio sito fatto in html come pagina del mio progetto... è da 2 giorni che ci provo ma nulla... non mi carica nemmeno il webserver!
il file all'interno della sd si chiama "index.htm"
ed ha un relativo codice css allegato... "csspagina.css"
Codice:
//Reset Timer Definer
//Define weserver
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 124 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
String HTTP_req; // stores the HTTP request
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
}
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
void loop() {
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n') {
Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
client.println("<TITLE>Nicolas Project</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>Casa Domotica</H1>");
client.println("<hr />");
client.println("
");
client.println("<H2>Arduino with Ethernet Shield</H2>");
client.println("
");
//BUTTONS
client.println("<a href=\"/?button1on\"\">Motorini a Sinistra</a>");
client.println("<a href=\"/?button1off\"\">Motorini a Destra</a>
");
client.println("
");
client.println("
");
client.println("<a href=\"/?button2on\"\">Led Blu</a>");
client.println("<a href=\"/?button2off\"\">Led Rosso</a>
");
client.println("
");
client.println("
");
client.println("<a href=\"/?button3on\"\">Reset</a>");
client.println("<a href=\"/?button3off\"\">Tasto inutile</a>
");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
client.stop();
Ovviamente lo faccio per cambiare il webserver che ho preso in una guida a caso in internet!
Grazie in aticipo!