I am trying to find the button codes for my IR remote using my Arduino UNO. I got this code from Instructables. The button code is supposed to appear in the serial monitor, but nothing shows up. I am almost positive that I connected the wires to the right place. I did not get any error messages. Thanks in advance😄!
Here is my code:
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE
The code you posted is only part of the complete sketch.... above that code box is:
#include <IRemote.h>
which you will need to paste into the top of your sketch... then try running it again.
Instructables seems to have zero error checking, and more often the projects are missing something... and sadly, so is create.arduino.cc... but you have this forum to help you get your stuff working.
You can check the IR Receiver by connecting a LED with a 1K resistor between the terminal marked out and 5volts. It will flash when you operate the remote control.
Be aware that the pinouts of those IR receiver types are not all the same so check the data sheet.
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(115200);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
Serial.println(results.value);
if (results.value == 0xFF00FF)
{
Serial.println("!");
}
irrecv.resume(); // Receive the next value
}
}