From e35d444ed059d093a1b3bf99da83928a38c2f27a Mon Sep 17 00:00:00 2001 From: Orhan-Timo Altan <timo.altan@th-koeln.de> Date: Fri, 25 Feb 2022 19:33:49 +0100 Subject: [PATCH] v1.0 --- BITsIRReciver.h | 67 ++++++++++++++++++++++++++++++++ README.md | 4 +- examples/IRReciver/IRReciver.ino | 16 ++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 BITsIRReciver.h create mode 100644 examples/IRReciver/IRReciver.ino diff --git a/BITsIRReciver.h b/BITsIRReciver.h new file mode 100644 index 0000000..40d926d --- /dev/null +++ b/BITsIRReciver.h @@ -0,0 +1,67 @@ +#ifndef BITSIIRRECIVER_H +#define BITSIIRRECIVER_H + +/* ********************************************** * + * IR Remote * + * * + * Button | Signal Kodierung * + * ---------------------------------------------- * + * Power Button | 69 * + * VOL+ Button | 70 * + * Func Button | 71 * + * Rewind Button | 68 * + * Play/Pause Button | 64 * + * Forward Button | 67 * + * Down Button | 7 * + * VOL- Button | 21 * + * UP Button | 9 * + * 0 Button | 22 * + * EQ Button | 25 * + * ST/REPT Button | 13 * + * 1 Button | 12 * + * 2 Button | 24 * + * 3 Button | 94 * + * 4 Button | 8 * + * 5 Button | 28 * + * 6 Button | 90 * + * 7 Button | 66 * + * 8 Button | 82 * + * 9 Button | 74 * + * ********************************************** */ +#include <IRremote.h> +// #define IR_USE_AVR_TIMER3 +const int irReceiverPin = 2; +IRrecv irrecv(irReceiverPin); +decode_results results; + +// Liste von oben nach unten sortiert +int commandlist[21] = {69, 70, 71, 68, 64, 67, 7, 21, 9, 22, 25, 13, 12, 24, 94, 8, 28, 90, 66, 82, 74}; + +class BITsIRReciver{ + public: + void init(){ + irrecv.enableIRIn(); + }; + + int ir_recv(){ + //if the ir receiver module receiver data + if (irrecv.decode()) + { + ir_command = irrecv.decodedIRData.command; + // Receive the next value + irrecv.resume(); + for (int i=0; i<21; i++) { + if (ir_command == commandlist[i]) { + ir_command_pos = i; + break; + } + } + return ir_command_pos; + } + }; + private: + int ir_command; + int ir_command_pos; +}; + +#endif \ No newline at end of file diff --git a/README.md b/README.md index d241950..7d6b72f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ -# BITs IR Empfänger +# **BITs IR Empfänger** + + diff --git a/examples/IRReciver/IRReciver.ino b/examples/IRReciver/IRReciver.ino new file mode 100644 index 0000000..95994ce --- /dev/null +++ b/examples/IRReciver/IRReciver.ino @@ -0,0 +1,16 @@ +#include "BITsIRReciver.h" + +BITsIRReciver bIRrec; +int command_index; + +void setup(){ + Serial.begin(115200); + bIRrec.init(); +} + +void loop(){ + command_index = bIRrec.ir_recv(); + Serial.println(command_index); +} + + -- GitLab