Arduino IR Transmitter Circuit

In this guide, you’ll learn how to set up an Arduino IR Transmitter circuit. It lets you control an IR (Infrared) LED and send any remote control code from your Arduino. This means you can use it to control your TV or anything else you feel like!

The Circuit

Arduino IR transmitter schematic

The circuit is pretty straightforward. Three buttons and an IR LED are connected to an Arduino. We’ll set up the pins D5-D7 with internal pullup resistors to avoid having to add them ourselves.

Parts List

Building the Circuit

Build the circuit according to the schematic.

In the image below, you can see a suggestion for how to connect your IR LED and the pushbuttons to your Arduino with a breadboard.

Arduino IR Transmitter on a breadboard

Upload the Code

Copy the following code to your Arduino IDE. This code initializes the IR transmitter and sets up the push buttons. When a button is pressed, a unique IR code is sent out.

#include <IRremote.h>

IRsend irsend;

void setup() {
  Serial.begin(9600);
  pinMode(5, INPUT_PULLUP); // SW1 connected to pin 2
  pinMode(6, INPUT_PULLUP); // SW2 connected to pin 3
  pinMode(7, INPUT_PULLUP); // SW3 connected to pin 4
  // The IR LED is connected to pin 3 (PWM ~) on the Arduino
}

void loop() {
  
  if (digitalRead(5) == LOW) { // When SW1 is pressed
    irsend.sendNEC(0x34895725, 32);  // Replace with your own unique code
    Serial.println("Code sent!");
    delay(30);
  } 

  else if (digitalRead(6) == LOW) { // When SW2 is pressed
    irsend.sendNEC(0x56874159, 32); // Replace with your own unique code
    Serial.println("Code sent!");
    delay(30);
  } 

  else if (digitalRead(7) == LOW) { // When SW3 is pressed
    irsend.sendNEC(0x15467823, 32); // Replace with your own unique code
    Serial.println("Code sent!");
    delay(30);
  } 
  
  else {
    Serial.println("Nothing to send");
    delay(30);
  } 

  delay(100);
}

Test Your Arduino IR Transmitter

After uploading the code to your Arduino, press each button and check the Serial Monitor. You should see “Nothing to send” until a button is pressed, at which point the corresponding IR code will be sent.

Make sure you point the IR LED toward the device you want to control.

Troubleshooting Tips:

  • Make sure your IR LED is connected to the correct pin and is oriented correctly with the positive and negative leads.
  • Ensure there are no loose connections on the breadboard and that all wires are fully inserted into the correct breadboard holes and Arduino pins.
  • If the buttons don’t seem to be working, check that they are wired with the correct polarity and that the INPUT_PULLUP mode is set correctly in the code.

By following these instructions, you should have a functional IR transmitter controlled by an Arduino. This can be used for various projects, including remote controls, interactive installations, and more. Remember to replace the unique codes in the irsend.sendNEC() function with codes that correspond to your device.

If you’re not sure which codes you need, check out our Arduino Remote Control project.

Have questions or suggestions? Drop a comment below, and help us improve these resources!

More Arduino Tutorials

Leave a Comment