The Sony IR Decoder code is written
in "C" and programmed into a PIC12C509 using a Parallax
(www.parallaxinc.com) programmer. The Sony remote control signals are 12 bits long and have a 2 ms start bit. I use the PIC timer to measure the start pulse and then I time each of the high portions of the 12 bit frame. A 700 us wide high portion is a "0" and a 1200us wide high portion is a "1". To reverse engineer the Sony remote signals, I used a Sharp IR receive module, powered it up and put a oscilliscope on the output lead. Holding a remote button will cause pulses to appear on the scope as long as you hold the button. I found for the Sony that some bit frames were always "1" or always "0" for TV and VCR, which allowed me to define an 8 bit value for each of the 12 bit Sony codes. Take a look at my code. I do a loop looking at each bit frame to determine if it is 700us or 1200us. I did three other important things to avoid false hits. There must be a valid start pulse (2-4 ms low), the generated code must be the same twice in a row, and the generated code must be one of the ones I've placed in a look up table in ROM. These checks keep the decoder from outputing bad values and from triggering on noise like sun light.