By 'mistake' I bought a couple of "Nibobee" robots. (got totally NOT what I expected)
Thet are based om ATmega16, so I flashed a bootloader .. all good so far.
I found this library for receiving IR codes:
The example (below) shows me the correct result on the serial monitor.. I dont need this, but rather the last two chars from the IR-code itself. I've searched the documentation I can find, but have not found the solution yet.
Help is appreciated..
/* https://github.com/z3t0/Arduino-IRremote. */
#include <IRremote.h>
#define IR_RECEIVE_PIN 25 // ATMEGA16
IRrecv IrReceiver(IR_RECEIVE_PIN);
byte code ;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
IrReceiver.enableIRIn(); // Start the receiver
}
void loop()
{
if (IrReceiver.decode())
{
IrReceiver.printResultShort(&Serial);
IrReceiver.resume(); // Enable receiving of the next value
// ********** I need the last two chars from the IR code *** like:
byte my_code= ??? ; // cannot fins a way to extrackt what I need
// ********************************
}
}
Is the IR code always the same length ?
What data type is it ?
Please post a complete sketch that illustrates what you want to do and an example of the received IR code and explain what data type you want the extracted data to be in
I cannot fint enough in the docs on github to complete. I'd really like to get those last two chars stored in a byte.
In the code, theres this link to the github lib.
Be aware that results is deprecated in that library. There is a read() method that returns a pointer to an IRData struct which contains the data that you're looking for.
Make sure that you check for NULL before using the IRData.
The struct:
struct IRData {
decode_type_t protocol; ///< UNKNOWN, NEC, SONY, RC5, ...
uint16_t address; ///< Decoded address
uint16_t command; ///< Decoded command
#if defined(ENABLE_EXTRA_INFO)
uint16_t extra; ///< Used by MagiQuest and for Kaseikyo unknown vendor ID
#endif
uint8_t numberOfBits; ///< Number of bits received for data (address + command + parity + etc.) to determine protocol length.
uint8_t flags; ///< See definitions above
uint32_t decodedRawData; ///< up to 32 bit decoded raw data, formerly used for send functions.
irparams_struct *rawDataPtr; /// pointer of the raw timing data to be decoded
};