#include <IRremote.h>
const int RECV_PIN = 7; // IR Receiver connected to digital pin 7
IRrecv irrecv(RECV_PIN); // Create IR receiver object
decode_results results; // Variable to store decoded results
void setup() {
Serial.begin(9600); // Initialize Serial Monitor
irrecv.enableIRIn(); // Start IR receiver
irrecv.blink13(true); // Blink onboard LED when signal is received
}
void loop() {
// Check if IR signal is received
if (irrecv.decode(&results)) {
// Print the received IR code in HEX format
Serial.println(results.value, HEX);
irrecv.resume(); // Prepare to receive the next signal
}
}
Instruction Details
Wiring: Connect IR receiver VCC to 5V, GND to GND, OUT to Digital Pin 7.
Library: Sketch → Include Library → Manage Libraries → search "IRremote" → Install.
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Open Serial Monitor (Tools → Serial Monitor) at 9600 baud. Point IR remote at receiver and press buttons. Hex codes display. Onboard LED blinks when signal received.
How to Use
Connect the required components as per the Pin Configuration above
Open Arduino IDE and create a new sketch
Copy and paste the code above
Select your Arduino board and COM port from Tools menu
Click the Upload button to upload the code to your Arduino
Open Serial Monitor (if applicable) to see the output