Part

Infrared remote, 21 buttons

NEC frames from twenty-one buttons: a 9 ms leader, 32 bits, and a repeat every 110 ms while you hold one.

See every part
  • 1 pin
  • 2 settings
  • In 3 projects
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
At a glance

The Infrared remote, 21 buttons in brief

What it is, and every setting the properties panel gives it.

The 21-button kit remote is the thin black handset sold with every VS1838B. It sends NEC: a 9 ms burst and a 4.5 ms gap, then 32 bits of address, inverted address, command and inverted command, least significant bit first, each a 562.5 microsecond burst and then a gap of the same for a zero or 1.6875 ms for a one. Its address is 0x00 and the commands are the tutorials’ set: CH- 0x45, 0 0x16, 1 0x0C, 2 0x18, 3 0x5E. The famous 0xFFA25D for CH- is the same frame read from the other end, each byte bit-reversed. The handset never wires to a board; the receiver’s OUT goes to any Uno digital pin or ESP32 GPIO. In Mokxi the single IR pin carries the beam with the 38 kHz carrier implied: wire it to the receiver’s IR pin, or point the handset at an unwired receiver within 7.5 m. Hold a button and a full frame goes out, then a repeat code every 110 ms. The classic mistake is treating each repeat as a new press. Other IR sources, a flat battery and every protocol but NEC are not modeled.

Family
Clocks and links
Pins
1
address
0
repeats
true
Pins

The one pin

Named as the editor names them, so a wire lands where you expect it.

  • IR
How to use it

How to use the 21-button IR remote with an Arduino

The kit handset sends NEC with address 0x00, and each button is a one-byte command: CH- is 0x45, CH 0x46, CH+ 0x47, 0 is 0x16, 1 is 0x0C, 2 is 0x18 and 3 is 0x5E. Older tutorials print the same buttons as 0xFFA25D and the like, the whole 32-bit frame read from the other end, so every byte comes out bit-reversed. This lamp project prints both for every press, so the two tables can be seen to be one.

The handset does not wire to the board. Its IR pin is the beam, drawn here to the receiver’s IR pin, and the receiver’s OUT goes to pin 2. Press 1, 2 or 3 to pick a lamp and 0 for off. Hold a button and the handset sends one frame, then a short repeat code every 110 ms; the sketch acts on repeats only for CH- and CH+, which dim the lamp while held. Treating every repeat as a fresh press is why volume buttons run away.

Part pin
Board pin
IR
The receiver’s IR pin (the beam)
Receiver OUT
Pin 2
Receiver VCC
5 V
Receiver GND
GND

The handset is the same for every board; on an ESP32 the receiver runs from 3.3 V and the same command bytes come back.

Arduino Uno: remote-controlled lampslive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
How it is modeled

What is true about the Infrared remote, 21 buttons, here

In its help article’s own words: what the simulation gets right, and where it stops.

Not modeled

The carrier and the air, as above. The automatic gain control, so this receiver never blanks. A real one turns its gain down under a long continuous burst and stops seeing anything, which is why NEC's leader is 9 ms and not 90. The tuning, so a burst at any rate at all is a burst here and two remotes on different carriers would interfere. The few hundred microseconds of edge error a real receiver has, which is what makes a decoder's tolerances necessary; here the edges are exact. And no protocol but NEC: no RC-5, no Sony SIRC, no extended NEC with a 16-bit address.

From Signals you time, not read, in full.

Projects

See the Infrared remote, 21 buttons in a project

3 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Boards

The boards it is shown on

This board has a built-in project with the Infrared remote, 21 buttons in it.

Libraries

Arduino libraries for the Infrared remote, 21 buttons

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Infrared remote, 21 buttons

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.