Posted 11 October 2025
My wife wants a low-intensity lamp she can turn on/off using any common TV remote from a distance of about 20ft. I found this set of four pairs of IR receiver and transmitter breakout boards on Amazon, and discovered the receiver can indeed detect the signal from a TF remote at well more than 20ft, so the project looks feasible.

Wiring is simplicity itself; just +5V, GND, and output pins.

Here are some representative scope grabs:


The idle output voltage is +5V, so I’m thinking that I can probably just low-pass the output and set a threshold.
The low-pass idea didn’t work – there wasn’t enough difference between the HIGH level and the average to comfortably use, so I wound up just counting the number of LOW occurrences in the receiver output, and that worked well (and eliminated two components as well). Here’s the finished prototype:

16 October 2025 Update:
This project is now finished, sort-of. The TV Remote Lamp works according to the wife, but there are some issues with the remote. If she uses the TV remote as we intended, and presses the ON/OFF button at the top – that will also turn the TV itself back on – an unintended consequence, but one that can be resolved by NOT using the ON/OFF button on the remote – any button will do.
Here’s a photo of the finished product and the accompanying enclosure, compliments of my Prusa Core ONE 3D printer:

And here is a photo of the ‘installation’ in our master bathroom:

As can be seen from the above photo, the sensor and LED are actually facing away from the bedroom and toward the mirror, but the sensor is perfectly happy with the reflected signal from the TV remote.
And here is the finished Arduino code for the Teensy 3.2:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
/* Name: TVRemoteLamp.ino Created: 10/12/2025 8:52:39 AM Author: FRANK_XPS_9530\Frank */ #include <EEPROM.h> #define INPUT_PIN 23 #define LAMP_PIN 3 #define TV_REMOTE_SIGNAL_COUNT 1000 #define TV_REMOTE_LOW_COUNT_THRESHOLD 100 //20% #define REPEAT_TRIGGER_DELAY_MSEC 1000 //From NiteLight project #define LED_MAX 250 #define LED_MIN 0 #define UP_BUTTON_PIN 14 #define DOWN_BUTTON_PIN 22 #define EEPROM_ADDRESS 0 #define PWM_INCREMENT 5 //#define OFFLINE uint8_t LED_Intensity = 0; elapsedMillis sinceLastOutput; bool bDone = false; uint16_t samp = 0; uint16_t samples[1000]; uint32_t Msec[1000]; uint16_t low_count = 0; bool bLampStatus = false; void setup() { #ifndef OFFLINE Serial.begin(115200); delay(2000);//needed for teensy #endif pinMode(INPUT_PIN, INPUT); //pinMode(LED_BUILTIN, OUTPUT); pinMode(LAMP_PIN, OUTPUT); //digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LAMP_PIN, LOW); //From NiteLight project pinMode(UP_BUTTON_PIN, INPUT_PULLUP); pinMode(DOWN_BUTTON_PIN, INPUT_PULLUP); LED_Intensity = EEPROM.read(EEPROM_ADDRESS); Serial.printf("Got = %d from EEPROM address %d\n", LED_Intensity, EEPROM_ADDRESS); } void loop() { if(IsTvRemoteActive()) { #ifndef OFFLINE Serial.printf("%lu: Remote signal detected: low_count = %d, bLampStatus = %s, LED_Intensity = %d\n", millis(), low_count, (bLampStatus == true? "ON":"OFF"), LED_Intensity); #endif bLampStatus = !bLampStatus; //toggle Serial.printf("bLampStatus toggled; it is now %s\n", (bLampStatus == true ? "ON" : "OFF")); if (bLampStatus) { Serial.printf("Setting lamp intensity to %d\n", LED_Intensity); analogWrite(LAMP_PIN, LED_Intensity); } else { Serial.printf("Setting lamp intensity to OFF\n"); analogWrite(LAMP_PIN, 0); } low_count = 0; delay(REPEAT_TRIGGER_DELAY_MSEC); } //From NiteLight project; do only if the lamp is ON if (bLampStatus) { AdjustLampIntensity(); } } bool IsTvRemoteActive() { //Purpose: // Determine if a TV remote signal is present //Inputs: // samp = uint16_t value acquired from receiver // samples = array of uint16_t values acquired from receiver // Msec = array of uint32_t millis() values // low_count = number of LOW values in samples array //Outputs: // TRUE if more than TV_REMOTE_LOW_COUNT_THRESHOLD LOW values recorded //Procedure: // Step1: Acquire TV_REMOTE_SIGNAL_COUNT values from INPUT_PIN // Step2: If the number of LOW values exceeds TV_REMOTE_LOW_COUNT_THRESHOLD, return TRUE; else return FALSE bool bResult = false; //Step1: Acquire TV_REMOTE_SIGNAL_COUNT values from INPUT_PIN for (int i = 0; i < TV_REMOTE_SIGNAL_COUNT; i++) { samp = digitalRead(INPUT_PIN); samples[i] = samp; Msec[i] = millis(); if (samp == LOW) { low_count++; } delay(1); } //Step2: If the number of LOW values exceeds TV_REMOTE_LOW_COUNT_THRESHOLD, return TRUE; else return FALSE if (low_count >= TV_REMOTE_LOW_COUNT_THRESHOLD) { bResult = true; } return bResult; } void AdjustLampIntensity() { bool UP = digitalRead(UP_BUTTON_PIN) == LOW; bool DOWN = digitalRead(DOWN_BUTTON_PIN) == LOW; #ifndef OFFLINE Serial.printf("In AdjustLampIntensity: UP = %s, DOWN = %s\n", (UP == true ? "TRUE" : "FALSE"), (DOWN == true ? "TRUE" : "FALSE")); #endif if (UP && !DOWN) { LED_Intensity += PWM_INCREMENT; #ifndef OFFLINE Serial.printf("Going UP, New Intensity = %d\n", LED_Intensity); #endif } else if (DOWN && !UP) { LED_Intensity -= PWM_INCREMENT; #ifndef OFFLINE Serial.printf("Going DOWN, New Intensity = %d\n", LED_Intensity); #endif } //keep PWM values bounded LED_Intensity = (LED_Intensity >= LED_MAX) ? LED_MAX : LED_Intensity; LED_Intensity = (LED_Intensity <= LED_MIN) ? LED_MIN : LED_Intensity; #ifndef OFFLINE Serial.printf("New Intensity = %d\n", LED_Intensity); #endif analogWrite(LAMP_PIN, LED_Intensity);//adj the intensity uint8_t oldIntensity = EEPROM.read(EEPROM_ADDRESS); #ifndef OFFLINE Serial.printf("oldIntensity = %d from EEPROM address %d\n", oldIntensity, EEPROM_ADDRESS); #endif if (oldIntensity != LED_Intensity) { #ifndef OFFLINE Serial.printf("Writing = %d to EEPROM address %d\n", LED_Intensity, EEPROM_ADDRESS); #endif EEPROM.write(EEPROM_ADDRESS, LED_Intensity); } } |