This project builds a QAM (Quadrature Amplitude Modulation) infrared remote control system using an ESP32 to transmit encoded commands and receive them back to control RGB LEDs. The transmitter uses a ROM-based address generator and clock divider to modulate infrared signals, while the receiver demodulates the QAM signal using in-phase and quadrature sampling to decode button presses. The guide includes a complete parts list, wiring diagrams for both transmitter and receiver circuits, ROM programming instructions, and step-by-step assembly from preparing the transmitter memory through final testing.
Builders will learn how QAM encoding works in practice, how to interface the ESP32 with discrete logic components and infrared optoelectronics, and how to implement coherent demodulation on a microcontroller. The firmware handles symbol timing, I/Q demodulation, nearest-neighbor decoding, and LED control logic.
Wiring diagram

Gather all the parts
Assemble it in 4 steps
1. Prepare the transmitter memory
Use an AT28C64B-compatible parallel EEPROM programmer to write data/qam-at28c64b.hex (Intel HEX format) starting at address zero, then verify the chip. This is waveform data, not microcontroller firmware. Deploy does not write this chip.
2. Build the transmitter clock and address wiring
On a separate breadboard, follow the transmitter wiring exactly. Numbers on the three chips are physical pin numbers counted from the notch. Place the three 100 nF capacitors close to their chips. Use the 5 V adapter with its own regulated 5 V USB source. Do not link either transmitter rail to the ESP32.
3. Wire the buttons and infrared LED
The buttons connect their address input to transmitter ground when pressed. The four weighted resistors meet at tx_limit.P1; tx_limit.P2 goes to the IR LED cathode. Its anode goes to transmitter 5 V because the buffer sinks current. Hold one button at a time for about half a second. Do not point the IR emitter into anyone's eyes.
4. Wire the receiver and test
Connect the detector collector to GPIO32, with 15 kΩ to 3V3, and both 33 kΩ and 10 nF to GND. Never connect the detector input to 5 V. Connect its emitter to GND. Connect outputs GPIO18 (red), GPIO19 (green), and GPIO23 (blue) to its LED anode through its own 330 Ω resistor, and each cathode to GND. Plug the ESP32 into USB and press Deploy. Let it start with the transmitter idle, then test a few centimeters apart indoors.
Review all connections
1. Connections between "detector" and "ESP32"
2. Connections between "rx_load" and "ESP32"
3. Connections between "rx_bias" and "ESP32"
4. Connections between "rx_filter" and "ESP32"
5. Connections between "r_red" and "ESP32"
6. Connections between "led_red" and "ESP32"
7. Connections between "r_green" and "ESP32"
8. Connections between "led_green" and "ESP32"
9. Connections between "r_blue" and "ESP32"
10. Connections between "led_blue" and "ESP32"
11. Connections between "clock" and "ESP32"
12. Connections between "rom" and "ESP32"
13. Connections between "driver" and "ESP32"
14. Connections between "ir_tx" and "ESP32"
15. Connections between "clock_bypass" and "ESP32"
16. Connections between "rom_bypass" and "ESP32"
17. Connections between "driver_bypass" and "ESP32"
18. Connections between "osc_r" and "ESP32"
19. Connections between "osc_guard" and "ESP32"
20. Connections between "osc_c" and "ESP32"
21. Connections between "btn_red" and "ESP32"
22. Connections between "pull_red" and "ESP32"
23. Connections between "btn_green" and "ESP32"
24. Connections between "pull_green" and "ESP32"
25. Connections between "btn_blue" and "ESP32"
26. Connections between "pull_blue" and "ESP32"
27. Connections between "btn_off" and "ESP32"
28. Connections between "pull_off" and "ESP32"
29. Connections between "dac0" and "ESP32"
30. Connections between "dac1" and "ESP32"
31. Connections between "dac2" and "ESP32"
32. Connections between "dac3" and "ESP32"
33. Connections between "tx_limit" and "ESP32"
Deploy the firmware
#include <Arduino.h>
constexpr int8_t cosine[] = {8,6,0,-6,-8,-6,0,6};
constexpr int8_t sine[] = {0,6,8,6,0,-6,-8,-6};
constexpr uint8_t leds[] = {18,19,23}, codes[] = {0x39,0xA6,0x5B,0xC4};
void waitFor(uint32_t t) { while (int32_t(micros()-t)<0) {} }
struct IQ { int32_t i,q; };
IQ readSymbol(uint32_t t, uint16_t slot) {
IQ r={0,0};
for (uint8_t n=0;n<16;++n) {
waitFor(t+uint32_t(n)*slot+slot/2);
int x=analogRead(32);
r.i+=int32_t(x)*cosine[n%8]; r.q+=int32_t(x)*sine[n%8];
}
return r;
}
int nearest(float a) {
int k=a < -2 ? 0 : a < 0 ? 1 : a < 2 ? 2 : 3;
return fabs(a-(2*k-3)) <= 0.85f ? k : -1;
}
void receive(uint32_t t, uint16_t slot) {
auto ref=readSymbol(t,slot); t+=16UL*slot;
float ri=ref.i, rq=ref.q, mag=ri*ri+rq*rq;
if (mag<40000) return;
uint16_t data=0;
for (uint8_t n=0;n<4;++n,t+=16UL*slot) {
auto r=readSymbol(t,slot);
float re=(r.i*ri+r.q*rq)/mag, im=(r.q*ri-r.i*rq)/mag;
int i=nearest(3*(re-im)), q=nearest(3*(re+im));
if (i<0 || q<0) return;
data=(data<<4)|(i<<2)|q;
}
uint8_t code=data>>8;
if (uint8_t(data)!=uint8_t(~code)) return;
for (uint8_t k=0;k<4;++k) if (code==codes[k]) {
for (uint8_t j=0;j<3;++j) digitalWrite(leds[j],j==k);
}
}
void setup() { analogReadResolution(10); analogSetPinAttenuation(32, ADC_11db); for (auto p:leds) pinMode(p,OUTPUT); }
void loop() {
static int32_t baseline=-1;
int x=analogRead(32);
if (baseline<0) baseline=int32_t(x)*256;
int dark=baseline/256;
if (dark-x<18) { baseline+=(int32_t(x)*256-baseline)/16; return; }
uint32_t start=micros();
int peak=dark-x;
while (micros()-start<22000) {
int depth=dark-analogRead(32);
uint32_t end=micros();
if (depth>peak) peak=depth;
if (depth<peak*4/5) {
uint32_t duration=end-start;
if (duration>=5000 && duration<=20000 && peak>=40) {
uint16_t slot=duration/16;
receive(end-100,slot);
}
break;
}
}
// Wait for the rest of a partial or valid packet before looking for another marker.
while (micros()-start<55000 && dark-analogRead(32)>8) {}
}
// Receiver wiring: detector on GPIO32, indicators on GPIO18, GPIO19 and GPIO23.Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




