Go Down

Topic: What does this code mean? (Read 556 times) previous topic - next topic

InduinoX

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }


I would like to know the use of each line and what does that &results within brackets mean?

Grumpy_Mike

Without knowing the rest of the code it is hard to tell but:-
irrecv.decode is a function to which you pass the address, the & bit, of a variable called results.


dhenry

Based on the name, I would guess that irrecv.decode() receives / decodes a message and puts that result in a struct called results. One of the elements in results is value, which is being sent serially.

JimboZA

It's from Ken Shirriff's IRrecvDemo sketch. When I worked with that sketch, I must say I didn't even bother to try and understand it, I just used it  8)
Arduino ethernet server here.... http://jimboza.gotdns.com:8085/

No PMs for help please

robtillaart

if you want to learn the details, you should "dissect" the library that you included in the code and follow it line by line.
Where did you got this code? there is probably some explanation/documentation in its neighbourhood.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

arduinohabib

When I used it, I forgot that it was being printed in hex and that caused me a lot of trouble.
What is man's best friend? The breadboard!

Go Up