Surbyte gracias por tu ayuda, solo que te comento, he leido acerca de write y read en EEPROM solo que estoy un poco perdido y no se como aplicarlo.
De igual manera agradezco tu valiosa ayuda pero creo que este es uno de esos momentos en que estoy bloqueado.
Saludos
He aqui el codigo:
#include <SPI.h>
#include <Ethernet.h>
#include <EEPROM.h>
//Declaración de la direcciones MAC e IP. También del puerto 80
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; //MAC
IPAddress ip(192, 168, 4, 31); //IP
EthernetServer servidor(80);
int PIN_LED1 = 9;
String readString1 = String(30);
String state1 = String(3);
int PIN_LED2 = 1;
String state2 = String(3);
int PIN_LED3 = 10;
String state3 = String(3);
int PIN_LED4 = 11;
String state4 = String(3);
int PIN_LED5 = 5;
String state5 = String(3);
int brillo = 0;
byte smDirectionPin = 2; //Direccion
int smStepPin = 3; //Stepper pin
void setup()
{
Ethernet.begin(mac, ip); //Inicializamos con las direcciones asignadas
servidor.begin();
Serial.begin(9600);
pinMode(PIN_LED1, OUTPUT);
analogWrite(PIN_LED1, LOW);
state1 = "BAJAS";
pinMode(PIN_LED2, OUTPUT);
digitalWrite(PIN_LED2, HIGH);
state2 = "OFF";
pinMode(PIN_LED3, OUTPUT);
digitalWrite(PIN_LED3, HIGH);
state3 = "OFF";
pinMode(PIN_LED4, OUTPUT);
state4 = "FLAT";
pinMode(PIN_LED5, OUTPUT);
pinMode(smDirectionPin, OUTPUT);
pinMode(smStepPin, OUTPUT);
}
void loop()
{
EthernetClient cliente = servidor.available();
if (cliente)
{
boolean lineaenblanco = true;
while (cliente.connected()) //Cliente conectado
{
if (cliente.available())
{
char c = cliente.read();
if (readString1.length() < 30) //Leemos petición HTTP caracter a caracter
{
readString1.concat(c); //Almacenar los caracteres en la variable readString
}
if (c == '\n' && lineaenblanco) //Si la petición HTTP ha finalizado
{
int LED1 = readString1.indexOf("LED1=");
int LED2 = readString1.indexOf("LED2=");
int LED3 = readString1.indexOf("LED3=");
int LED4 = readString1.indexOf("LED4=");
int LED5 = readString1.indexOf("LED5=");
if (readString1.substring(LED1, LED1 + 6) == "LED1=T" && state1 == "BAJAS" )
{
for (brillo = 0; brillo <= 255; brillo = brillo + 1) {
analogWrite(9, brillo);
delay(20);
}
state1 = "ALTAS";
}
else if (readString1.substring(LED1, LED1 + 6) == "LED1=T" && state1 == "MEDIAS" )
{
for (brillo = 60; brillo <= 255; brillo = brillo + 1) { // Subo de medias a altas
analogWrite(9, brillo);
delay(30);
}
state1 = "ALTAS";
}
if (readString1.substring(LED2, LED2 + 6) == "LED2=T" && state1 == "ALTAS")
{
for (brillo = 255; brillo >= 60; brillo = brillo - 1) { // Bajo de altas a medias
analogWrite(9, brillo);
delay(30);
}
state1 = "MEDIAS";
}
else if (readString1.substring(LED2, LED2 + 6) == "LED2=T" && state1 == "BAJAS")
{
for (brillo = 0; brillo <= 60; brillo = brillo + 1) { // Subo de bajas a medias
analogWrite(9, brillo);
delay(40);
}
state1 = "MEDIAS";
}
if (readString1.substring(LED3, LED3 + 6) == "LED3=T" && state1 == "MEDIAS")
{
for (brillo = 60; brillo >= 0; brillo = brillo - 1) { // Bajo de medias a bajas
analogWrite(9, brillo);
delay(40);
}
state1 = "BAJAS";
}
else if (readString1.substring(LED3, LED3 + 6) == "LED3=T" && state1 == "ALTAS")
{
for (brillo = 255; brillo >= 0; brillo = brillo - 1) { // Bajo de altas a bajas
analogWrite(9, brillo);
delay(20);
}
state1 = "BAJAS";
}
if (readString1.substring(LED4, LED4 + 6) == "LED4=T" && state4 == "SCOPE" ) //Control de Masking Flat
{
digitalWrite(smDirectionPin, HIGH); //Direccion de giro.
state4 = "FLAT";
for (int i = 0; i < 1200; i++) { // Gira 6 vueltas en un sentido ( 400 pasos por vuelta)
digitalWrite(smStepPin, HIGH);
delayMicroseconds (1200);
digitalWrite(smStepPin, LOW);
delayMicroseconds (1200);
}
}
if (readString1.substring(LED5, LED5 + 6) == "LED5=T" && state4 == "FLAT") // COntrol de Masking Scope
{
digitalWrite(smDirectionPin, LOW ); //Direccion de giro.
state4 = "SCOPE";
for (int i = 0; i < 1200; i++) { // Gira 6 vueltas en otro sentido ( 400 pasos por vuelta)
digitalWrite(smStepPin, HIGH);
delayMicroseconds (1200);
digitalWrite(smStepPin, LOW);
delayMicroseconds (1200);
}
}
//Cabecera HTTP estándar
cliente.println("HTTP/1.1 200 OK");
cliente.println("Content-Type: text/html");
cliente.println();
//Página Web en HTML
cliente.println("<html>");
cliente.println("<head>");
cliente.println("<title>CINEREMOTE</title>");
cliente.println("</head>");
cliente.println("<body width=100% height=100%>");
cliente.println("<center>");
cliente.println("<h1>LUCES</h1>");
cliente.print("
");
cliente.print(state1);
cliente.print("
");
cliente.println("<input type=submit value=ALTAS style=width:200px;height:75px onClick=location.href='./?LED1=T\'>");
cliente.println("<input type=submit value=MEDIAS style=width:200px;height:75px onClick=location.href='./?LED2=T\'>");
cliente.println("<input type=submit value=BAJAS style=width:200px;height:75px onClick=location.href='./?LED3=T\'>");
cliente.print("
");
cliente.println("<h1>MASKING</h1>");
cliente.print(state4);
cliente.print("
");
cliente.println("<input type=submit value=FLAT style=width:200px;height:75px onClick=location.href='./?LED4=T\'>");
cliente.println("<input type=submit value=SCOPE style=width:200px;height:75px onClick=location.href='./?LED5=T\'>");
cliente.println("</center>");
cliente.println("</body>");
cliente.println("</html>");
cliente.stop();//Cierro conexión con el cliente */
readString1 = "";
}
}
}
}
}