Programming the PIC Microcontroller with MBasic

According to Internet lore, the average household has between five and seven remote controls. Before starting this chapter, I collected a box full to test one Zenith, two Nakamichis, two Mitsubishis, one Samsung, one Toshiba, one Hitachi, and two Radio Shack universal remote controls just by going through our house. Two belong to equipment long since scrapped as uneconomical to repair, but the rest are in more or less common use.
Although the first "cordless" TV remote controls used ultrasonic technology (and without electronics in the remote, no less, employing mechanically stroked tuning forks) when inexpensive LEDs became available, digital infrared transmission became the norm. (Low power radio is used for garage door openers, automobile remote locks and the like.)
With an inexpensive IR receiver module connected to a PIC, it's easy to decode most remote controls. Once decoded, we then may use the techniques we've seen in other Chapters to control a variety of devices. We might use a relay to turn a light off and on, or we might translate volume up/down buttons to adjust audio levels through a SPI-controlled MCP42010 digital potentiometer.
Finding definitive information on IR remote controls isn't easy; the consumer electronic manufacturers hold the information closely. I've pieced together this chapter from research published on the Internet by inspired hackers, supplemented with measurements of the assortment of remote controls available to me.
First, let's look at the lowest level of the transmission and reception and at this level, all remotes work alike. When you push a...