Ciao a tutti !
Ho realizzato un programma che mi permette di azionare il mio condizionatore da remoto, sfruttando la connessione di Internet di casa. Il funzionamento del programma è abbastanza semplice, tuttavia ho un problema di occupazione di memoria. Ecco il programma:
#include <Ethernet.h>
#include <SPI.h>
#include <WebServer.h>
#include "IRremote.h"
IRsend irsend;
int khz=38; //NB Change this default value as neccessary to the correct modulation frequency
// ON and 2O C° with 1 FAN heat
unsigned heat[] = {3000,3000,3000,4400,550,1600,600,550,550,1650,550,550,550,550,550,1650,550,550,550,1650,500,550,550,1650,550,550,550,500,600,500,600,550,550,550,550,1650,500,550,550,600,500,1700,500,550,550,550,550,550,550,600,500,550,550,550,550,550,550,550,550,1650,550,1650,550,1650,500,1650,550,1650,550,550,550,550,550,550,550,550,550,1650,550,1650,550,500,550,550,550,1700,500,1650,550,550,550,500,600,550,550,550,550,550,550,550,550,550,550,1650,500,1700,500,550,550,550,550,550,550,550,550,550,550,600,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,500,550,1700,500,550,550,550,550,550,550,1650,550};
// OFF the A/C
unsigned OFF[] = {3100,2900,2950,4400,700,1500,700,400,700,1500,700,400,650,450,550,1650,550,550,650,1500,600,500,600,1600,600,500,600,500,600,450,650,450,600,550,550,550,550,550,550,600,500,1600,600,500,600,500,600,550,550,500,600,500,600,550,550,550,550,1600,600,500,600,500,600,500,550,1650,550,1600,600,500,600,500,600,550,550,550,550,1600,600,1600,550,550,550,550,550,1650,550,1600,600,550,550,500,600,500,600,550,550,550,550,500,600,500,600,1600,600,1600,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,500,600,550,550,550,550,500,600,500,600,500,600,1600,600,500,600,1600,550,550,550,1600,600,550,550,550,550};
// ON and 23° with 2 FAN cold
unsigned cold[] = {3050,3000,3000,4400,550,1600,600,550,550,1650,550,550,550,550,550,1650,550,500,600,1600,550,550,550,1650,550,1650,550,1650,550,550,550,550,550,500,600,1600,550,550,550,550,550,1650,550,550,550,550,550,550,550,550,550,550,550,550,550,500,600,1650,500,550,550,600,500,1700,500,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1650,550,550,550,500,550,1650,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,550,550,550,550,550,550,550,550,500,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,1650,550,1600,600,550,550};
static byte mac_Add[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
WebServer webserver("", 80);
String state = "off";
void Start(WebServer &server, WebServer::ConnectionType type,
char *url_param, bool param_complete)
{
server.httpSuccess();
if (type != WebServer::HEAD)
{
String s = "";
if (param_complete == true)
{
s = url_param;
if ( s == "cold")
{
Serial.println("cold");
state = "cold";
irsend.sendRaw(cold, sizeof(cold)/sizeof(int), khz);
}
if ( s == "warm")
{
Serial.println("warm");
state = "warm";
irsend.sendRaw(heat, sizeof(heat)/sizeof(int), khz);
}
if ( s == "off")
{
Serial.println("off");
state = "off";
irsend.sendRaw(OFF, sizeof(OFF)/sizeof(int), khz);
}
}
// web page
server.print(
"<html><head><meta name='viewport' content='width=200px'/></head><body>"
"<h1>A/C Arduino Remote Controller Page!</h1>");
if(state=="off"){
server.print("<h2>Stato AC : off </h2>");
}
if(state=="cold"){
server.print("<h2>Stato AC : condizionatore </h2>");
}
if(state=="warm"){
server.print("<h2>Stato AC : pompa di calore </h2>");
}
server.println("<h1> </h1>
");
server.println("<a href='/?cold'><img src='http://ismanettoneblog.altervista.org/blog/wp-content/uploads/2014/02/cold.png'>""<a href='/?warm'><img src='http://ismanettoneblog.altervista.org/blog/wp-content/uploads/2014/02/warm.jpg'>
"
"<a href='/?off'><img src='http://ismanettoneblog.altervista.org/blog/wp-content/uploads/2014/02/off.png'>");
}
}
void setup()
{
Ethernet.begin(mac_Add);
webserver.setDefaultCommand(&Start);
webserver.addCommand("index.htm", &Start);
Serial.begin(9600);
webserver.begin();
delay(100);
}
void loop()
{
webserver.processConnection();
}
Avete qualche consiglio per aumentare lo spazio disponibile ? Sto utilizzando Arduino Uno