Arduino Experiment: Build an Infrared Remote Control System

Difficulty Level: Intermediate

In this experiment, we'll build a simple infrared (IR) remote control system using an IR receiver and an IR remote. The Arduino will decode the remote’s signals and perform actions based on the button presses, such as toggling an LED or controlling a servo motor.

Required Components

Wiring Instructions

Code Explanation

This system works by receiving IR signals from the remote. Each button on the remote sends a unique hexadecimal code, which the Arduino can interpret and use to trigger specific actions.

Libraries Needed

We will use the IRremote library to decode the signals from the remote. Install it from the Arduino Library Manager before uploading the code.

Arduino Code


// Include the IRremote library
#include 

const int RECV_PIN = 11;  // Pin connected to the IR receiver
const int LED_PIN = 13;   // LED to be controlled by the remote
IRrecv irrecv(RECV_PIN);  // Create instance of 'irrecv' to receive signals
decode_results results;   // Create structure to store received codes

void setup() {
  Serial.begin(9600);     // Initialize serial communication for debugging
  irrecv.enableIRIn();    // Start the receiver
  pinMode(LED_PIN, OUTPUT);  // Set the LED pin as an output
}

void loop() {
  if (irrecv.decode(&results)) {  // Check if an IR signal is received
    Serial.println(results.value, HEX);  // Print the received value in hexadecimal

    // Example remote codes (you need to change these based on your remote)
    if (results.value == 0xFFA25D) {  // Power button pressed
      digitalWrite(LED_PIN, !digitalRead(LED_PIN));  // Toggle the LED
    }

    irrecv.resume();  // Prepare to receive the next value
  }
}
            

Upload and Test

  1. Wire the IR receiver and the Arduino as described above.
  2. Upload the code to your Arduino.
  3. Open the Serial Monitor and point your IR remote at the receiver.
  4. Press any button on your remote, and the corresponding code will appear on the Serial Monitor.
  5. Note the hex value for a specific button (e.g., the power button) and update the code to toggle the LED when that button is pressed.

How It Works

When the Arduino detects a signal from the IR receiver, it decodes the signal using the IRremote library and identifies which button on the remote was pressed by comparing the signal’s hex value to known values. Based on the button press, the Arduino can perform different tasks like turning an LED on/off or controlling a motor.

Conclusion

By using an IR remote and receiver, you can easily create a remote-controlled system for home automation or any other project where wireless control is needed. This experiment can be expanded by adding more devices (like motors, fans, etc.) and writing code to control them via remote commands.