Skip to content

Commit

Permalink
Change HelloSIRC12 example to HelloSIRCbasic
Browse files Browse the repository at this point in the history
Now it also shows ext data from the SIRC20 protocol
  • Loading branch information
LuisMiCa committed Jan 10, 2022
1 parent 4f6c58f commit 0139b08
Showing 1 changed file with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/* A simple example, using the IRsmallDecoder library,
* for testing remote controls that use the Sony SIRC12 protocol.
/* A simple example, using the IRsmallDecoder library, for testing remote controls
* that use the Sony SIRC12, SIRC15 or SIRC20 protocols.
*
* Notes:
* - For the SIRC15 or SIRC20 protocols, use IR_SMALLD_SIRC15 or IR_SMALLD_SIRC20
* instead of the IR_SMALLD_SIRC12 (in the #define ...);
* - Unlike IR_SMALLD_SIRC, IR_SMALLD_SIRC12/15/20 do not have the keyHeld data member;
* - IR_SMALLD_SIRC20 has an additional data member (ext);
* - Each keypress on a SIRC remote, usually sends three signal frames. (The two additional
* signal repetitions are ignored in the IR_SMALLD_SIRC, but not in the IR_SMALLD_SIRC12/15/20);
* - IR_SMALLD_SIRC12 will receive signals from SIRC15 and SIRC20
* but the codes will not be correct;
* - Each keypress on a SIRC remote, usually sends three signal frames. The two additional
* signal repetitions are ignored in the IR_SMALLD_SIRC, but not in the IR_SMALLD_SIRC12/15/20;
* - IR_SMALLD_SIRC12 will receive signals from SIRC15 and SIRC20, but the codes will not be correct;
* - In a similar way, IR_SMALLD_SIRC15 will receive signals from SIRC20, but not from SIRC12.
*
* In this example it's assumed that the IR sensor is connected to digital pin 2 and
Expand All @@ -20,21 +17,39 @@
* or the README.pdf file in the extras folder of this library.
*/

#define IR_SMALLD_SIRC12 //1st: define which protocol to use and then,

#define IR_SMALLD_SIRC12 //1st: define which protocol to use;
//#define IR_SMALLD_SIRC15
//#define IR_SMALLD_SIRC20

#include <IRsmallDecoder.h> //2nd: include the library;
IRsmallDecoder irDecoder(2); //3rd: create one decoder object with the correct digital pin;
irSmallD_t irData; //4th: declare one decoder data structure;

void setup() {
Serial.begin(250000);
Serial.println("Waiting for a SIRC12 remote control IR signal...");
Serial.println("Addr\t Cmd");
#if defined(IR_SMALLD_SIRC12)
Serial.println("Waiting for a SIRC12 remote control IR signal...");
Serial.println("Addr\tCmd");
#elif defined(IR_SMALLD_SIRC15)
Serial.println("Waiting for a SIRC15 remote control IR signal...");
Serial.println("Addr\tCmd");
#elif defined(IR_SMALLD_SIRC20)
Serial.println("Waiting for a SIRC20 remote control IR signal...");
Serial.println("Addr\tCmd \tExt");
#endif
}

void loop() {
if (irDecoder.dataAvailable(irData)) { //5th: if the decoder has some new data available,
Serial.print(irData.addr, HEX); //6th: do something with the data.
Serial.print("\t ");
Serial.println(irData.cmd, HEX);
Serial.print(" \t");
#if defined(IR_SMALLD_SIRC12) || defined(IR_SMALLD_SIRC15)
Serial.println(irData.cmd, HEX);
#else
Serial.print(irData.cmd, HEX);
Serial.print(" \t");
Serial.println(irData.ext, HEX);
#endif
}
}

0 comments on commit 0139b08

Please sign in to comment.