Projects / TV remote relay switch

TV remote relay switch

Intermediate50 minGuided buildReviewed
Arduino Uno5VD11D7GNDIR receiverOFFRelay module12 V lamp
Relay OFF

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 5 done
  1. UNOVS1838B

    Place the IR receiver

    Dome facing you, check its pin order on the module: usually OUT, GND, VCC.

  2. UNOVS1838B

    Wire the receiver

    OUT to D11, GND to GND, VCC to 5V.

  3. UNOON

    Wire the relay module

    IN to D7, VCC to 5V, GND to GND.

  4. UNOON

    Connect the low-voltage load

    Put the relay's COM and NO in series with a 5 to 12 V lamp or LED strip and its own supply.

  5. UNO

    Upload and learn a button

    Upload, open the serial monitor, press the remote button you want. Press it again to switch.

In short

How do you build a TV remote relay switch?

Press a button on any TV remote to switch a relay on and off, for a low-voltage lamp or LED strip. You need Arduino Uno R3, IR receiver VS1838B, Relay Module 5V and Breadboard 830 Tie Points. It takes 5 steps and about 50 minutes.

Level
Intermediate
Time
About 50 min
Parts
4

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
IR receiver OUTUno D11Remote signal
IR receiver VCC and GNDUno 5V and GNDPower
Relay module INUno D7Switch signal
Relay module VCC and GNDUno 5V and GNDCoil power
Relay COM and NOIn series with a 5 to 12 V lamp or LED stripThe switched load

Code

Arduino IDE. Install the "IRremote" library (version 4 or later). Switch only low-voltage loads in this build: never mains without a qualified person and an enclosed, rated module.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <IRremote.hpp>

const int IR_PIN = 11, RELAY = 7;
uint16_t onOffCode = 0;   // learned from the first button you press
bool on = false;

void setup() {
  Serial.begin(9600);
  pinMode(RELAY, OUTPUT);
  IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);
  Serial.println("Press the remote button you want to use");
}

void loop() {
  if (!IrReceiver.decode()) return;
  uint16_t cmd = IrReceiver.decodedIRData.command;
  bool repeat = IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT;
  IrReceiver.resume();
  if (repeat) return;
  Serial.print("Command 0x"); Serial.println(cmd, HEX);
  if (onOffCode == 0) { onOffCode = cmd; Serial.println("Learned"); return; }
  if (cmd == onOffCode) {
    on = !on;
    digitalWrite(RELAY, on ? HIGH : LOW);  // some modules switch on LOW: swap if needed
    Serial.println(on ? "Relay ON" : "Relay OFF");
  }
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

Press the remote button you want to use

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
First pressSerial shows a command code and "Learned"
Same button againRelay clicks, "Relay ON"
Other buttonsCode printed, relay does not change

If it does not work

No codes appear

Check OUT is on D11, and point the remote straight at the dome from under 3 m.

Relay switches on boot or works inverted

Many modules are active LOW: swap HIGH and LOW in the code.

Board resets when the relay clicks

Power the relay module from a separate 5 V supply with a shared GND.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the TV remote relay switch?

Arduino Uno R3, IR receiver VS1838B, Relay Module 5V and Breadboard 830 Tie Points.

How long does the TV remote relay switch take to build?

About 50 minutes for a intermediate maker, in 5 steps.

How do I know the TV remote relay switch works?

First press: Serial shows a command code and "Learned". Same button again: Relay clicks, "Relay ON". Other buttons: Code printed, relay does not change.

No codes appear: what should I check?

Check OUT is on D11, and point the remote straight at the dome from under 3 m.

Relay switches on boot or works inverted: what should I check?

Many modules are active LOW: swap HIGH and LOW in the code.

Board resets when the relay clicks: what should I check?

Power the relay module from a separate 5 V supply with a shared GND.