someone know how I can do to save the information from leds in sd card and I can see on the internet ? if LEER was click on the web page I want to read the information from my sd card but I do not know where is the mistake . I read about the configurations of pins in the examples from arduino and It say that both aplications use the similar pins . I am not sure how I can to do to works with two applications.Are there another library?
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0x5C, 0x16};
IPAddress ip(192,168,1,5);
byte gateway [] = {192,168,1, 1};
byte subred [] = {255, 255, 255, 0};
int led = 7;
const int chipSelect = 4;
EthernetServer server(80);
String cad=String(100);
File myFile;
const char html[] =
//"HTTP/1.1 200 OK"
//"Content-Type: text/html"
"<!DOCTYPE HTML>"
"<html lang='es'>"
"<head><title> ARDUINO </title></head>"
"<body bgcolor='#FFFFFF' text='#FFFFFF' marginheight='125' marginwidth='125' link='#0033CC' vlink='#0033CC' alink='#0033CC'>"
"<center> <font face='Times New Roman, Times, serif' color='#0033CC' size='45'> ARDUINO </center>"
"<center> <font face='Times New Roman, Times, serif' color='#0033CC' size='5'><a href='http://www.arduino.cc'>arduino.cc </a> </center>"
"
"
"<form method=get><input type=hidden name=leer value=1><input type=submit value=LEER></form>"
"</body></html>";
void setup()
{
pinMode(led, OUTPUT);
Ethernet.begin(mac,ip,gateway,subred);
server.begin();
Serial.begin(9600);
Serial.print("Initializing SD card...");
pinMode(chipSelect, OUTPUT);
digitalWrite(chipSelect,HIGH);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop()
{
cad="";
EthernetClient client = server.available();
if (client) {
server.print(html);
while (client.connected()) {
if (client.available()) {
char c = client.read();
cad=cad+c;
if (c == '\n')
{
if ( cad.lastIndexOf("leer") > 0)
{
digitalWrite(led,HIGH);
delay(1000);
myFile = SD.open("call.txt");
if (myFile) {
Serial.println("call.txt:");
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
} else {
Serial.println("error opening call.txt");
}
}
client.stop();
}
}
}
}
}