hn.today

How to read codes from (many) IR remote controls with as little code as possible

bitbanksoftware.blogspot.com4 points0 comments
Screenshot of How to read codes from (many) IR remote controls with as little code as possible

The project explains how to decode common NEC infrared remote-control signals with a small amount of custom code, rather than relying on large libraries such as Arduino IRremote or Linux LIRC. NEC sends 32 bits after a start signal: an 8-bit address and its inverse, followed by an 8-bit command and its inverse. Each bit is represented by a short mark and a space whose duration distinguishes zero from one. The author combines the address and command into a 16-bit button identifier. In practice, the sampled remotes had shorter start signals than the formal specification, so the decoder accepts a looser threshold. It also divides measured pulse durations by 512 rather than 562.5 microseconds, simplifying the calculation while retaining enough accuracy.

The implementation uses a low-cost IR receiver and a Seeed Xiao nRF52840 board, though an ESP32-S3 is also mentioned. Unreliable readings on the nRF52840 were traced to Arduino’s low-resolution default timer; enabling the chip’s hardware cycle counter fixed the problem. The finished device learns seven remote buttons, saves their codes to flash, and translates recognized presses into USB keyboard commands for media playback, volume, mute, and optional caption controls. A USB HID library handles keyboard output. The account is useful both as a compact protocol-decoding guide and as a practical build outline, including hardware setup, timing pitfalls, learning mode, and bootloader considerations.

Read on bitbanksoftware.blogspot.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Hardware

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.