相关文章推荐
decode_results results; int Q1 = 2;              // Dig Out int Q2 = 3;              // Dig Out int Q3 = 4;              // Dig Out int Q4 = 5;              // Dig Out int BEEP_PIN = 6;        // Beeper pin int Code = 0; void setup()   Serial.begin(9600);   irrecv.enableIRIn();  // Start the receiver   pinMode(Q1, OUTPUT);  // Setup the H-bridge outputs   pinMode(Q2, OUTPUT);   pinMode(Q3, OUTPUT);   pinMode(Q4, OUTPUT);   pinMode(BEEP_PIN, OUTPUT);   digitalWrite(Q1, HIGH);  // Set Motor to stop as initial state   digitalWrite(Q2, LOW);   digitalWrite(Q3, HIGH);   digitalWrite(Q4, LOW);   digitalWrite(BEEP_PIN, HIGH);  // Beeper on   delay (500);   digitalWrite(BEEP_PIN, LOW);  // Beeper off // MAIN LOOP void loop() {   if (irrecv.decode(&results)) {     //Serial.println(results.value, HEX);     Code = results.value;     irrecv.resume(); // Receive the next value

I've read through the API documentation and not sure if it hasn't been updated as yet, but I get this error message and my results all print out as zero.

warning: 'bool IRrecv::decode(decode_results*)' is deprecated: You should use decode() without a parameter. [-Wdeprecated-declarations]
if (irrecv.decode(&results))

Thank you very much - I was browsing through the API documentation and the official website.

I am still however slightly confused on how to use this.

Can I please be provided with a link for further reading or a code snippet.

Thanks

shawn_t:
Thank you very much - I was browsing through the API documentation and the official website.

I am still however slightly confused on how to use this.

Can I please be provided with a link for further reading or a code snippet.

Thanks

I have checked through the example sketches.

I am unsure as to how to get the HEX values from the decode object. (If it is called an object - I'm not familiar with object orientated programming).

All the example sketches call functions to print various information to the serial monitor on the protocol, timing and HEX code of each button press. I can obviously see the HEX code for each button, but don't know how to obtain and assign it to a variable.

I need to do a switch case statement for volume up and volume down pressed which will control a H-bridge circuit.

It looks to me like you would find that in 'IRrecv.decodedIRData.decodedRawData' . The example base doesn't seem to include anything that doesn't just print values. This 3.0.0 code base looks like it's been pushed quite far without clean up. The documentation in the wiki appears to be mostly out of date.

I suggest starting with the basic receive demo and adding that to it. I didn't have time to dig into this, but it looks like maybe some kind of command decode has been added, or at least will be added. That is in 'IRrecv.decodedIRData.command'.

Here is where all that stuff "lives":

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) - to determine protocol length if different length are possible (currently only Sony).
    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

shawn_t:
I have checked through the example sketches.

I am unsure as to how to get the HEX values from the decode object. (If it is called an object - I'm not familiar with object orientated programming).

All the example sketches call functions to print various information to the serial monitor on the protocol, timing and HEX code of each button press. I can obviously see the HEX code for each button, but don't know how to obtain and assign it to a variable.

I need to do a switch case statement for volume up and volume down pressed which will control a H-bridge circuit.

Hi shawn_t, did you manage to get a way to assign the code to a variable? I've got the same issue with that library update.

Hi yomhei,

You can use *IrReceiver.decodedIRData.decodedRawData *
I checked and I see that in this object the input data is stored.
You can also verify the hex code received by printing it in your Serial monitor:
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);

Hi yomhei,

You can use IrReceiver.decodedIRData.decodedRawData
I checked and I see that in this object the input data is stored.
You can also verify the hex code received by printing it in your Serial monitor:
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);

Thx dragovich. That'll teach me to read the GitHub wiki before to ask, Everything was there.

 
推荐文章