Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Risolto! aggiungere un comando IR
#1
Ciao a tutti,
non riesco a capire come aggiungere un segnale ir da inviare dal pannello.
Code:
{
   if (Msg.equals("#W10")) {irsend.sendRaw(Signal_ON_0, sizeof(Signal_ON_0)/sizeof(int), khz); Serial.println("#L10");}    // Turn OFF LED 1 and Relay if switch is OFF
   if (Msg.equals("#W11")) {irsend.sendRaw(Signal_OFF_1, sizeof(Signal_OFF_1)/sizeof(int), khz); Serial.println("#L11");}    // Turn ON LED 1 and Relay if switch is ON
   Msg = "";
 }
Ho provato cosi' ma il pannello mi da errore.
Qualcuno potrebbe gentilmente aiutarmi?
Grazie
Enzo
Reply
#2
Controlla il serial.println..... che dovrebbe essere serial1.println.....
Reply
#3
Ciao uso arduino uno e se non sbaglio il serial1.println è per la leonardo.
Reply
#4
E' vero io uso il LilyPad Arduino USB e prevede il serial1....

Specifica meglio l'errore che ti da e a sto punto metti tutto il codice
Reply
#5
(05-09-2016, 06:14 AM)Dok Wrote: E' vero io uso il LilyPad Arduino USB e prevede il serial1....

Specifica meglio l'errore che ti da e a sto punto metti tutto il codice

Ciao ecco il codice che uso:
Code:
void setup() {

 // Initialize Serial Port
 Serial.begin(57600);
 
 // Let uPanel to start
 delay(3000);

 // Discharge old partial messages and activate real-time response
 Serial.println("\n$PING 200");
 
 // Send Panel (A LED and a Switch)
 Serial.println("$P:D!228;T*15:&#956Panel-Arduino Example 3;{%100,3!88F,228}*20/L1G:0:LED;*10/W1:0;");
 
}

String Msg;

void loop() {
 int khz=38;

unsigned int Signal_ON_1[] = {4472,4316,612,1580,636,464,608,1580,608,1580,636,464,608,492,608,1580,608,492,608,488,608,1580,608,488,640,460,612,1580,608,1580,608,488,612,1580,608,484,612,488,612,1576,636,1552,612,1576,616,1580,608,1576,612,1580,608,1580,608,1580,636,464,636,460,636,460,612,488,640,460,612,484,608,488,636,1556,636,460,612,484,636,1556,612,1576,632,464,616,484,608,1580,636,460,640,1552,636,1552,636,460,612,488,612,1580,608,1576,620,5160,4476,4304,616,1576,612,484,636,1552,616,1576,612,484,616,484,612,1576,612,488,608,492,632,1556,608,488,608,492,608,1580,636,1552,612,484,612,1580,604,492,612,488,632,1556,608,1580,608,1580,608,1580,612,1580,608,1580,608,1580,608,1580,608,488,612,488,612,484,612,488,612,484,616,484,608,492,608,1580,608,488,636,460,612,1580,612,1580,608,484,640,464,608,1576,612,484,616,1580,608,1580,632,460,616,484,612,1576,612,1584,592}; //AnalysIR Batch Export (IRremote) - RAW
unsigned int Signal_OFF_0[] = {4496,4304,608,1580,612,488,608,1580,612,1580,608,484,616,484,640,1556,608,492,608,484,612,1580,612,484,616,484,608,1584,608,1580,636,464,612,1576,608,488,612,1580,612,1580,712,1476,636,1556,608,484,640,1556,608,1580,608,1584,608,484,612,488,612,488,744,356,612,1576,612,488,608,492,608,1580,636,1556,632,1556,636,460,612,488,612,484,636,464,740,360,608,488,612,484,636,460,612,1584,608,1576,612,1580,612,1580,608,1576,624,5156,4476,4308,612,1576,612,488,612,1576,616,1576,636,460,612,484,640,1556,608,488,612,484,616,1576,632,464,612,488,608,1584,632,1556,608,488,612,1580,608,488,612,1580,608,1580,612,1580,608,1580,608,488,612,1576,612,1584,604,1580,608,492,608,488,612,488,632,464,612,1580,608,492,608,488,608,1584,608,1576,612,1576,616,484,608,492,608,488,612,488,612,484,608,492,608,492,608,488,612,1576,608,1580,612,1580,608,1580,608,1584,532}; //AnalysIR Batch Export (IRremote) - RAW

 int c;
 while ((c = Serial.read()) > '\n') Msg += (char) c;  // Read incoming chars, if any, until new line
 if (c == '\n')                                       // is the message complete?
 {
   if (Msg.equals("#W10")) Serial.println("#L10"); irsend.sendRaw(Signal_OFF_0, sizeof(Signal_OFF_0)/sizeof(int), khz);   // Turn OFF LED 1 if switch is OFF
   if (Msg.equals("#W11")) Serial.println("#L11"); irsend.sendRaw(Signal_ON_1, sizeof(Signal_ON_1)/sizeof(int), khz);     // Turn ON LED 1 if switch is ON
   Msg = "";
 }
   
}
Quando apro il pannello mi dà parecchi errori.
Dove sbaglio?
Grazie a tutti anticipatamente
Reply
#6
prova un po' così

Code:
#include <IRremote.h>

IRsend irsend;


void setup() {

// Initialize Serial Port
Serial.begin(57600);

// Let uPanel to start
delay(3000);

// Discharge old partial messages and activate real-time response
Serial.println("\n$PING 200");

// Send Panel (A LED and a Switch)
Serial.println("$P:D!228;T*15:&#956Panel-Arduino Example 3;{%100,3!88F,228}*20/L1G:0:LED;*10/W1:0;");

}

String Msg;

void loop() {
int khz=38;

unsigned int Signal_ON_1[] = {4472,4316,612,1580,636,464,608,1580,608,1580,636,464,608,492,608,1580,608,492,608,488,608,1580,608,488,640,460,612,1580,608,1580,608,488,612,1580,608,484,612,488,612,1576,636,1552,612,1576,616,1580,608,1576,612,1580,608,1580,608,1580,636,464,636,460,636,460,612,488,640,460,612,484,608,488,636,1556,636,460,612,484,636,1556,612,1576,632,464,616,484,608,1580,636,460,640,1552,636,1552,636,460,612,488,612,1580,608,1576,620,5160,4476,4304,616,1576,612,484,636,1552,616,1576,612,484,616,484,612,1576,612,488,608,492,632,1556,608,488,608,492,608,1580,636,1552,612,484,612,1580,604,492,612,488,632,1556,608,1580,608,1580,608,1580,612,1580,608,1580,608,1580,608,1580,608,488,612,488,612,484,612,488,612,484,616,484,608,492,608,1580,608,488,636,460,612,1580,612,1580,608,484,640,464,608,1576,612,484,616,1580,608,1580,632,460,616,484,612,1576,612,1584,592}; //AnalysIR Batch Export (IRremote) - RAW
unsigned int Signal_OFF_0[] = {4496,4304,608,1580,612,488,608,1580,612,1580,608,484,616,484,640,1556,608,492,608,484,612,1580,612,484,616,484,608,1584,608,1580,636,464,612,1576,608,488,612,1580,612,1580,712,1476,636,1556,608,484,640,1556,608,1580,608,1584,608,484,612,488,612,488,744,356,612,1576,612,488,608,492,608,1580,636,1556,632,1556,636,460,612,488,612,484,636,464,740,360,608,488,612,484,636,460,612,1584,608,1576,612,1580,612,1580,608,1576,624,5156,4476,4308,612,1576,612,488,612,1576,616,1576,636,460,612,484,640,1556,608,488,612,484,616,1576,632,464,612,488,608,1584,632,1556,608,488,612,1580,608,488,612,1580,608,1580,612,1580,608,1580,608,488,612,1576,612,1584,604,1580,608,492,608,488,612,488,632,464,612,1580,608,492,608,488,608,1584,608,1576,612,1576,616,484,608,492,608,488,612,488,612,484,608,492,608,492,608,488,612,1576,608,1580,612,1580,608,1580,608,1584,532}; //AnalysIR Batch Export (IRremote) - RAW

int c;
while ((c = Serial.read()) > '\n') Msg += (char) c;  // Read incoming chars, if any, until new line
if (c == '\n')                                       // is the message complete?
{
  if (Msg.equals("#W10")) {Serial.println("#L10"); irsend.sendRaw(Signal_OFF_0, sizeof(Signal_OFF_0) / sizeof(Signal_OFF_0[0]), khz);}  // Turn OFF LED 1 if switch is OFF
  if (Msg.equals("#W11")) {Serial.println("#L11"); irsend.sendRaw(Signal_ON_1, sizeof(Signal_ON_1) / sizeof(Signal_ON_1[0]), khz);}     // Turn ON LED 1 if switch is ON
  Msg = "";
}
}
Reply
#7
Niente da fare, mi da:
error at column 36:missing vr0209 terminator(Wink
error at column 48:missing vr0209 terminator(Wink

lo smile eqivale a ;
Reply
#8
risolto. l'errore era nel unsigned int che è stato messo dentro il void loop per sbaglio.
Deve stare al di fuori del void setup e del void loop.
Ciao a tutti
Reply
#9
Bene, strano però che negli esempi proposti per l'arduino compaia dentro il loop.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)