How do i make an infrared sensor detect a signal then simply print something?

Hi! I'm a newbie to infrared, i wasn't sure which section to put this under but since it is on the programming side of infrared i thought i would put it under that.

#include <IRremote.h>

int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;

void setup()

void loop()
if (irrecv.decode(&results))
Serial.println(results.value, DEC); 


This is for a car mp3 controller and i believe it converts hexadecimal to decimal when a button is pressed. However, lets say i wanted it so that when i press the button labelled 1 which in decimal form is 16724175, how would i go about detecting that the button has been pressed and then printing "Button Pressed"? If anyone could help it would be great!
Also, buttons in hexadecimal.

Something like

if (results == 16724175) {
1 Like

Not sure we can help but without knowing make model etc we do not have a chance. A schematic of your circuit as wired would also help.

Blue wire goes to pin 11,
Red goes to 5V
Black to ground

Not sure if that is what you mean but that’s it

Run some tutorials for the hardware selected.
If you are happy with the results of the tutorials you can merge this to your project.
Have a nice day and enjoy coding in C++.

Best is to start with the examples from the IRremote library.

Thanks! I will do!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.