Go Down

Topic: Ajuda com codigo ir raw via web server (Read 127 times) previous topic - next topic

vitorlube

Ola, estou aprendendo a "brincar" com o arduino, e estou tentando criar um codigo para controlar meu a/c e outros eletronicos, consegui um codigo pronto na internet e alterei ele com meus proprios comandos ir, porem nao consigo fazer funcionar, alguem poderia testar meu codigo??
Estou usando um arduino uno r3 uma ethernet shield e um led ir...

Code: [Select]


#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"
#include <IRremote.h>

template<class T>
inline Print &operator <<(Print &obj, T arg)
{ obj.print(arg); return obj; }

//IR Variable declaration
IRsend irsend;

//acon
unsigned int airpower[38] = {8300,4150,550,1550,500,1600,500,1550,550,550,500,1600,500,550,550,1550,500,1600,500,4150,550,1550,550,1550,550,500,550,1550,550,500,550,500,550,500,550,500,650,};

//tempup
unsigned int tempdown[38] = {8250,4200,450,1650,450,1650,450,1650,500,550,450,1650,450,600,450,1650,450,1650,450,4200,450,600,500,550,500,1600,500,600,450,600,500,550,450,600,450,600,550,};

//tempdown
unsigned int tempup[38] = {8300,4150,500,1600,450,1650,450,1600,500,600,500,1600,450,600,500,1600,500,1600,500,4150,500,1600,500,550,500,1600,500,550,550,500,550,500,550,500,550,550,550,};

//auto
unsigned int autop[38] = {8300,4150,500,1600,500,1600,500,1600,500,550,500,1600,500,550,500,1600,500,1600,500,4150,500,1600,500,1600,500,550,500,600,450,600,450,600,450,600,450,600,550,};

//powersaver
unsigned int pwsaver[38] = {8250,4200,500,1600,500,1600,500,1550,500,600,450,1650,450,600,500,1600,500,1600,450,4200,500,550,500,1600,500,550,500,1600,500,550,500,550,500,550,550,550,550,};

// MAC
static uint8_t mac[] = { 0xA2, 0xB8, 0xD8, 0xD4, 0xFD, 0x43 };

// IP
static uint8_t ip[] = { 192, 168, 1, 103 };

#define PREFIX ""

WebServer webserver(PREFIX, 80 );


void acOn(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  if (type == WebServer::POST)
  {
    server.httpFail();
    return;
  }

  //server.httpSuccess(false, "application/acOn");
  server.httpSuccess();

  //Replace for your IR Code here.
  irsend.sendRaw(airpower,38,38);
  delay(40);
}

void tempUp(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  if (type == WebServer::POST)
  {
    server.httpFail();
    return;
  }

  server.httpSuccess();
 
 //Replace for your IR Code here.
  irsend.sendRaw(tempup,38,38);
  delay(40);
 
}

void tempDown(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  if (type == WebServer::POST)
  {
    server.httpFail();
    return;
  }

  server.httpSuccess();

  //Replace for your IR Code here.
  irsend.sendRaw(tempdown,38,38);
  delay(40);
}


void autoP(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  if (type == WebServer::POST)
  {
    server.httpFail();
    return;
  }

  server.httpSuccess();

  //Replace for your IR Code here.
  irsend.sendRaw(autop,38,38);
  delay(40);
}


void pwSaver(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  if (type == WebServer::POST)
  {
    server.httpFail();
    return;
  }

  server.httpSuccess();

  //Replace for your IR Code here.
  irsend.sendRaw(pwsaver,38,38);
  delay(40);
}

void setup()
{

  Ethernet.begin(mac, ip);
  webserver.begin();

  webserver.addCommand("acon", &acOn);
  webserver.addCommand("tempup", &tempUp);
  webserver.addCommand("tempdown", &tempDown);
  webserver.addCommand("autop", &autoP);
  webserver.addCommand("pwsaver", &pwSaver);
}

void loop()
{
  webserver.processConnection();

}


luisilva

Deste código o que está a funcionar e o que não?
Por exemplo, já testou apenas a parte dos comandos IR para colocar o A/C a funcionar? E a parte do Web Server?

Go Up