This project lets an Arduino press the buttons of a battery-powered radio remote control. Send a letter from your computer over USB, and the Arduino briefly “presses” the matching ON or OFF button, so remote-controlled sockets switch lights, heating or other equipment. Optocouplers keep the Arduino electrically separate from the remote, and LEDs show which channel is active. The same idea works with any simple remote whose buttons just connect two contacts.
Datasheet verified by us. The Arduino pin current limits quoted here were checked against the ATmega328P datasheet (pages 308 and 323). The sketch was compiled for an Arduino Uno with the Arduino toolchain. The optocoupler and LED values are typical figures, so check them against the datasheet of the parts you buy.
- Each remote button gets one Arduino pin, a resistor, an LED and one optocoupler channel. Four channels (ON and OFF each) use pins 2 to 9.
- Send
Hand the Arduino pulses pin 3 for one second: channel 1 ON. Sendhand it pulses pin 2: channel 1 OFF. - The Arduino only touches the remote’s low-voltage button contacts. Never connect it to mains wiring.
- Use about 220 Ω instead of 47 Ω in the LED branch. A 47 Ω resistor pushes the pin close to its 40 mA absolute maximum.
How it works
A battery remote has a row of buttons. Each button is a pair of contacts on the circuit board that the button’s rubber pad connects when you press it. The Arduino cannot be wired straight to those contacts without risking the remote’s electronics, so each button is replaced by the output side of an optocoupler: a small chip with an LED on one side and a light-sensitive transistor on the other. When the Arduino lights the LED, the transistor conducts and connects the two contacts, exactly as a finger would. Nothing electrical passes between the two sides, only light.
- The computer sends a letter over USB at 9600 baud.
- The sketch looks the letter up in a list and finds the pin for that button.
- The pin goes HIGH for one second. Current flows through the resistor, the indicator LED and the optocoupler LED.
- The optocoupler’s transistor connects the remote’s contacts for that second, the remote sends its radio code, and the socket switches.
What you need
Battery remote with 4 channels (ON/OFF buttons) and matching remote sockets
Dual optocouplers, 8-pin DIP (4 of them)
8 resistors, 220 Ω
8 indicator LEDs (optional but useful)
Stripboard or prototype board
Ribbon cable and header pins
Enclosure
Soldering iron, solder, cutters
The original build used a HomeEasy HE300 controller with HE302S remote sockets, and four RS 308-613 dual optocouplers. A dual optocoupler holds two channels in one 8-pin package, so one chip covers the ON and OFF buttons of one channel.
Wiring one channel
| From | To | Why |
|---|---|---|
| Arduino pin 3 | 220 Ω resistor, LED, optocoupler pin 1 | Presses the channel 1 ON button |
| Arduino pin 2 | 220 Ω resistor, LED, optocoupler pin 4 | Presses the channel 1 OFF button |
| Optocoupler pins 2 and 3 | Arduino GND (next to pin 13) | Return path for both LEDs |
| Optocoupler pins 6 and 7 (joined) | The common contact of the channel 1 buttons on the remote | Shared side of both buttons |
| Optocoupler pin 8 | The ON contact of the remote | Output for the ON button |
| Optocoupler pin 5 | The OFF contact of the remote | Output for the OFF button |
Why 220 ohms, not 47
In each branch the current passes through three things in a row: the resistor, the indicator LED (about 2 V for a red LED) and the optocoupler’s LED (about 1.2 V). With a 5 V pin and the typical drops, the current is (5 – 2 – 1.2) divided by the resistor:
| Resistor | Current per pin (typical) | Against the ATmega328P limits |
|---|---|---|
| 47 Ω | about 38 mA | Close to the 40 mA absolute maximum per pin, and above the 20 mA at which the datasheet guarantees the output voltage |
| 220 Ω | about 8 mA | Well inside both limits, and enough to drive most optocouplers |
The datasheet gives 40 mA as the absolute maximum DC current per I/O pin and 200 mA for the VCC and GND pins (datasheet p. 308). A pin is guaranteed to hold at least 4.2 V while supplying 20 mA at 5 V, and the sum of the source currents on each port group must stay under 150 mA (datasheet p. 323). Only one channel is pressed at a time in this sketch, so the totals are no problem. The current figures above are typical values; check the forward voltage and the required LED current in the datasheet of the optocoupler you buy.
Building the board
- Solder the optocoupler sockets and resistors on stripboard, and a row of header pins that plugs into the Arduino’s digital headers. Cut the tracks between the two sides of each optocoupler.
- Solder the LED branches: pin, resistor, LED, optocoupler LED pin. Put the LEDs where you can see them through the enclosure.
- Join optocoupler pins 2 and 3 together and run them to GND.
- Join pins 6 and 7 of each optocoupler and connect them to the common contact of that channel on the remote’s circuit board. Connect pin 8 and pin 5 to the ON and OFF contacts.
- Before connecting the Arduino, check for short circuits between neighbouring tracks with a multimeter.
The sketch
The sketch keeps two parallel lists: the command letters and the pins. When a letter arrives, it finds its position, raises the matching pin for one second and lowers it again. Adding a fifth channel means adding two letters and two pins to the lists. The sketch compiles for an Arduino Uno to 2,142 bytes.
// duino4projects.com
// Serial commands press the buttons of a battery-powered remote through optocouplers.
// Capital letter = channel ON, small letter = channel OFF. Send one character per command.
// H / h channel 1 (heating) pins: ON = 3, OFF = 2
// S / s channel 2 (security) pins: ON = 5, OFF = 4
// G / g channel 3 (garden lights) pins: ON = 7, OFF = 6
// L / l channel 4 (lamp) pins: ON = 9, OFF = 8
const unsigned long PULSE_MS = 1000; // how long each "button press" lasts
const char commands[] = "HhSsGgLl";
const byte pins[] = { 3, 2, 5, 4, 7, 6, 9, 8 }; // same order as the commands
void setup() {
Serial.begin(9600);
for (byte i = 0; i < sizeof(pins); i++) {
pinMode(pins[i], OUTPUT);
digitalWrite(pins[i], LOW);
}
Serial.println(F("Ready. H/h S/s G/g L/l"));
}
void loop() {
if (Serial.available() > 0) {
char c = Serial.read();
for (byte i = 0; i < sizeof(commands) - 1; i++) {
if (c == commands[i]) {
digitalWrite(pins[i], HIGH); // LED and optocoupler LED on: the remote "button" is pressed
delay(PULSE_MS);
digitalWrite(pins[i], LOW); // released
Serial.print(F("Sent "));
Serial.println(c);
}
}
}
}
| Send | Channel | Pin pulsed | Result |
|---|---|---|---|
H / h |
1 (heating) | 3 / 2 | ON / OFF |
S / s |
2 (security) | 5 / 4 | ON / OFF |
G / g |
3 (garden lights) | 7 / 6 | ON / OFF |
L / l |
4 (lamp) | 9 / 8 | ON / OFF |
Open the Arduino serial monitor at 9600 baud, type H and press Send. The channel 1 ON LED lights for one second, the sketch prints “Sent H”, and the socket switches on.
Controlling it from your computer
Anything that can write a character to the serial port can drive the board: the serial monitor, a script on a schedule, or a program that reacts to the time of day or a light sensor. For example, a scheduled task that sends G at sunset and g at 23:00 switches the garden lights without you being there. To reach it from outside the house, use a VPN or a trusted remote-access tool for the computer, and do not expose the serial port or the computer directly to the internet.
When something does not work
| Symptom | Likely cause | Fix |
|---|---|---|
| LED lights but the socket does not switch | Output wires on the wrong polarity, or wrong contacts | Swap the two output wires of that button. Check the contacts with a multimeter on the remote’s button. |
| Nothing happens when a letter is sent | Wrong port or baud rate, or the letter is the wrong case | Select the Uno’s port, set the monitor to 9600 and send a capital letter for ON, a small letter for OFF. |
| Remote works by hand but never from the Arduino | Pulse too short or the remote needs a longer press | Raise PULSE_MS in the sketch. |
| Arduino resets when a command is sent | The serial monitor opened the port and reset the board | Wait for the “Ready” message before sending the first command. |
| Socket switches on its own | Neighbouring remote or another remote using the same code | Re-pair the socket with the remote. |
Project variants: Arduino home automation with remote control
- IR Remote Controlled Home Automation using Arduino: IR remote controlled home automation
- Project: Home Automation Using IR Remote Control: home automation using an IR remote control
- Easy DIY Home Automation (using servo switches) using arduino: home automation with servo switches
- PC Controlled Home Automation using Arduino: PC controlled home automation
Related projects: other ways to switch things at home
- Internet Devices for Home Automation using Arduino: internet devices for home automation
- Home Automation: Drapes using Arduino: automatic drapes
- Home Automation using Arduino and ESP8266 Module: home automation with an ESP8266 module
Quick answers
Check your own build
Test each channel in turn with the remote in your hand: press the real button once to see the socket respond, then send the same letter from the serial monitor and confirm the same result. Test ON and OFF for all four channels before you close the enclosure, and check the resistor values against the table above.
Project resources and downloads
- 📄 ATmega328P datasheet (Microchip DS40002061B)
PDF, 653 pages, about 33 MB. Absolute maximum ratings (page 308) and I/O pin current limits (page 323). - 📚 Arduino Serial reference
Web page. The functions used to read the letters. - 📚 Arduino
Web page. The IDE and board information.
