IR-related ASCII Schematics


[Document Version: 1.00] [Last Updated: 12/12/96]

1. Infra Red Remote Transponder

From: squish@endor.uucp (Shishin Yamada)

[...] I built a remote-transponder, which lets me send signals from a small receiver into closed (opaque door) cabinets, and around corners, etc. Anyways, the cheif problem is just stray environmental noise with any slowly changing amplitude modulated IR signal (lots of 60 Hz noise, and sunlight noise). Most IR remotes work around a 40KHz carrier, so that they can just pulse this digitally, and just bandpass filter it at the receiving end. This boosts the range of unfocused IR remotes to tens of feet (around 20-30 feet). Adding two IR Leds helps alot, by sending out more IR signals.

Anyways, the following is a cutout from the group sci.electronics. Most of which had been posted in the past month (I guess many news-servers might not go back one month, so I re-posted. Hope nobody minds). There is included transmitter and receiver modules. Personally, I find the Sharp IR Receiver module (avaiable at Radio Shack) to be the easiest darn thing to use. You just pop in +5V and ground, and you get the demodulated signal out (a high/low version of whatever was riding on the 40KHz IR signal). It comes with simple application notes. Hope this info helps you out.

Oh, lastly, if you're looking for ANALOG transmitters, I would look into Radio-Electronics recently for posts about their "Air-Hop" voice transmitter, or into Forrest Mims III "Circuit Cookbook." They both show how to do FM modulation onto IR (much, much better than AM).


                           30Hz BANDPASS FILTER          gain = 1
                                                            Q = 4
        +5V                  .1uF
         |                    ||            330K
         \            +-------||----+-------/\/\/--------+
         /            |       ||    |                    |
         \ 100K       |             |                    |
         /            |             |                    |
         \            |             |                    |
         |            |      .1uF   |     ___            |
         |     39K    |       ||    |    |   \___        |
         +----\/\/\---+-------||----+----|-      \___    |
IR       |            |       ||         |           \   |
Detector |            |                  |   LM3900   >--+---+
         |            |                  |        ___/       |
    ||---+            \             +----|+   ___/           |
    ||                /             |    |___/               |
    ||---+            \ 5.6K        \                        |
         |            /             /                        |
         |            \             \ 1M                     |
         |            |             /                        |
         |            |             \                        |
        GND          GND            |                        |
                                   +5V                       |
              |                  ___
              |        120K     |   \___
              +-------\/\/\-----|-      \___
     SCHMITT TRIGGER            |           \
                                |   LM3900   >--+------ Vout
                                |        ___/   |
                           +----|+   ___/       |
                           |    |___/           |
                           |                    |
                           |                    |
                 1.1M      |         1.1M       |
           +5V --\/\/\-----+---------\/\/\------+
                                              ----- 1uF

           +5V                       555         +5V
            |                       TIMER         |
            /                   +-----------+     |
            \                  1|           |8    |
            / 10ohms   GND -----|GND     Vcc|-----+
            \                   |           |     \
            /                   |           |     /
            |                  3|           |     \ 2.2K
            +-------------------|OUT        |     /
            |                   |           |7    \
            |                   |      DISCH|-----+
            |                  4|-          |     \
IR LED  ||--+          +5V -----|R          |     /
       <||                      |           |     \ 200K
        ||--+                   |           |     /
            |                  2|           |6    \
            |               +---|TRIG  THRES|-----+------+
            |               |   |           |     |      |
            |               |   +-----------+     |      |
           GND              |                     |    ----- .1uF
                            |                     |    -----
                            +---------------------+      |

2. Cheap 40KHz clock

(From Sebastian Filzek)

Use a 40KHz Xtal and a 74C14 schmitt trigger:

             ________  <---------------- 2.2 M resistor
         ___|  2M2   |___
         |  |________|   |
         |               |
         |               |
         |     |\        |
         |     | \       |
         +-----|  O------+--------> Output 40KHz
         |     | /
         |     |/  gate 1 of 74C14
        XXX   40KHz Xtal
This circuit has worked for me in many applications. (it might be an idea to buffer the signal befor using it. (There are still 5 unused gates in the 'C14.. :-)

3. A very STABLE 40khz generator

(From Rodney Radford)

A circuit that I have used before is based on the CD4060 (14stage binary counter) and a 640Khz ceramic resonator. The CD4060 is basically an oscillator and a ripple counter to divide the 640khz down to something more usable.

Here is the pinout of the CD4060 (frequencies are assuming a 640khz input signal into pins 10/11/12 - circuit shown below):

      160hz  1 |    | 16  Vcc
       80hz  2 |    | 15  625hz
       40hz  3 |    | 14  2.5khz
      10khz  4 |    | 13  125hz
      20khz  5 |    | 12  \
       5khz  6 |    | 11   >---- see sub-circuit below
      40khz  7 |    | 10  /
        GND  8 |    |  9  NC
Sub-circuit for a 640khz ceramic resonator:

      12 >----------------------+
                         740pf  |    (you may be able to obtain
      11 >-------+----+---|(----+     a resonator with builtin
                 |    |         |     capacitors and three leads)
        640khz  ---   \         |
         res.    O    / 1Mohm   |
                ---   \         |
                 |    |         |
      10 >-------+----+---|(----+
                         740pf  |
     GND &gt;----------------------+<>
A nice part about this circuit is that it delivers a STABLE 40khz signal, as well as delivering several other frequencies that can be used to modulate the 40khz carrier. For example, the person that designed this circuit (Ken Boone, member of Triangle Amateur Robotics) used it to build several beacons in his yard to serve as navigation points for a robotic lawnmower. By diode-OR'ing the results of the 40khz carrier and one of the lower frequencies (such as the 125Hz) line to drive a ring of IR-LEDs, he could locate the beacon and tell which, of several, beacons he had found.

This circuit has proven to be VERY stable, and is fairly inexpensive (about $1.50 for the CD4060 and 640Khz ceramic resonator).

4. Minimizing SUN's noise in IR reception


A 'baffle' is a perforated disk or disks spaced inside your 'shade tube'. The idea is to trap all reflections, leaving only the light coming in on the exact axis of the tube to strike the IR Detector.

   |        |        |        |
 DET                                   &lt;--- IR LIGHT
   |        |        |        |

            ^Baff    ^Baff    ^Baff
Off-axis light, 'noise', will be caught by the baffles and dissipated through reflection between the baffles. Paint the inside of your tube black ... in fact, check into what paints/coatings are 'black' to IR wavelenghts. Just because a paint LOOKS black does not mean it won't reflect IR.

Check into an astronomy or optics group to get the formula for the ideal spacing of the baffles and how big a hole should be in them. Getting this right will improve your system performance.

5. Build an Infrared night scope

(From -=-= Wes =-=-)

Building a night scope is easy if you have the heart of it which is the image intensifier part. I would recommend using the PVS-5 module which uses 'MCP' or Micro Channel Plate technology. This is a U.S. 2nd generation device and is rated at 15,000 times light gain. The resolution is one of the best on the market. It was used in Desert Storm and released to the surplus market about 2 1/2 years ago. However, it can't be exported out of the U.S. :-( The device can be found for between $350 to $700 depending on the quality you want in terms how new it is or if it used. I will list a couple of vendors at the end.

I have built several of these scopes with and without targeting lasers. The laser will kill your battery in no time and I recommend not using one for normal use as the PVS-5 has excellent response without it (unless you want to scare the crap out of someone in total darkness running around your yard. Just put a laser dot on his forehead and let him figure out where it came from and what is at the end of a 30.30 :-) Anyway, you will need the following:

When you receive your module do not pull on the power wires or they will break off inside of the power supply and you now have a several hundred dollar paper weight! Do no handle the front screen if possible. If you do, wipe it clean with a optical lens cleaner. DO NOT TWEEK THE TWO POTS IN THE POWER SUPPLY!! These pots adjust the ABC (Automatic Brightness Control) and AGC (Automatic Gain Control). If the pots are set too high, a flashover will occur in the Micro Channel Plates and burn out one or more which means that part of the display is dead. This is noticed by a black spot on the display when the PVS-5 is turned on. With that out of the way, lets continue...

Using fine sandpaper or cheesecloth, smooth out the inside surface of the larger PVC pipe. Test fit the PVS-5 module by sliding it into the PVC pipe. It should fit snug but not tight. Continue sanding until the fit is snug. Next, remove the module and wipe down the inside of the pipe. Spray the inside flat black and let it dry. Once its dry, mount the front lens mount to the PVC pipe and mount the lens. Slide the PVS-5 into the other end and slide it to about 2">from the lens. Focus the lens to infinity and close the shutter all the way so that only a pinhole is open. Point it towards an object 10 feet or better away. Apply 3 volts to the PVS-5 and slide it back and forth until the clearest image can be seen on the display screen. Move the focus on the lens in and out and insure the image remains clear. Secure the PVS-5 into the housing with the silicon rubber. DO NOT GET IT ON THE DISPLAY OR THE FRONT SCREEN! In case you are wondering why you can use the PVS-5 in normal lighting (like a shop or lab) its because of the automatic brightness function. The PVS-5 was designed to eliminate blooming problems with muzzle flash and bright light sources such as gun fire and explosions. Just don't open the shutter all the way (though it wouldn't hurt it).

After the silicon rubber is cured, we now start on the 'fun' (ugh !) part. This is time consuming (about an hour) and requires a little patience. The eyepiece that I use is a 35mm lens that is 'reversed' I.E. you look through the front of it rather than the back. The reason I do this is to eliminate the pincushion effect of the PVS-5's concave screen. But you can use anything that will magnify the image (even a 8X jeweler's eye loupe which I used on my first one with 'passable' results). Anyway, if you choose to use a 35mm lens like I did, then we have to rework the lens. First unscrew the whole body of the lens. Most will have a small screw stop that won't allow you to unscrew it completely unless the screw is removed. Once the lens is separated from the shutter and rear optic, clean the grease off of the threads. Next, try a fit test into the PVC housing. If the lens is too tight, grind the threads down until the lens fits snug, but not overly tight. Next, drill a small hole 1/2" from the rear of the PVS-5 at the top to pass the power wires through. Now, put the lens onto the PVC and press it as far in as it will go. Now apply power to the PVS-5. The image will be blurred. Here is the fun part. Remove power and the lens and using a hacksaw or bandsaw, cut 1/2" off of the PVC pipe and try it again. Continue doing this until it 'starts' to come into focus. Once it starts to come into focus, saw the PVC in 1/8" sections. Continue until the display is crystal clear. This has to be done whether you use a 35mm lens or not. Whatever you choose, the housing has to be cut to focus the eyepiece correctly. At this point, you need to remove the eyepiece, front lens mount and front lens. Cover the front and rear of the housing with paper and masking tape. Now you can spray paint the housing whatever color you choose. I do mine in flat satin black and they come out great ! Set it aside to dry. After its dry, remove the paper and masking tape. Blow out any particles. Insure that the PVS-5 is secure with silicon rubber. Touch up any scrapes of the flat black paint on the inner surface to eliminate reflections. Clean the front and back of the PVS-5 with optical lens cleaner. Re-assemble the front lens mount and front lens. Insert eyepiece. Drill two 1/16" hole about 1/2" from the rear of the housing on either side of the eyepiece. Secure the eyepiece with two small 2-56 screws. Apply power and insure all is well so far.

Now for the battery holder. This is what the 3/4" PVC pipe and end caps are for. Put an end cap on one end and place it on the main housing so that the front end cap is against the front lens mount. Measure back from the eyepiece about 3/4" and put a mark on the small PVC pipe. Cut the pipe on the mark and place the other end cap on the small pipe. Put the whole thing on the main housing and check the fit. If it is to close to the eyepiece, mark and cut it where it is at a suitable distance. Next, mark exactly where the wires are coming out of the housing on the bottom of the battery holder pipe and drill a small hole there so that the wires go straight into the battery holder. Next, drill a hole for the pushbutton about 1/2" from the end of the front end cap. Remove both caps and set aside for now. Measure 1 1/2" from the rear of the battery holder and place a mark here. Now saw with a hacksaw about 3/4 of the way through the battery holder to form a slot. Grind the washer so it fits flush into the slot (I.E. the round top is even with the round top of the battery holder). Next nip a small slot out of the side of the washer so that the ground wire can pass through it. Insert the washer into the slot and insure it is flush then epoxy it into place by putting a dab of epoxy OPPOSITE the slotted side inside of the battery holder. Next, take a small piece of insulated hookup wire and strip one end. Form a loop that will let a 4-40 screw pass through it and solder the loop. Next place a 4-40 flat head screw into the hole in the center of the washer with the head pointing towards the battery. Place the loop of the wire on the other side and secure it with a 4-40 nut. Solder the other end to one side of the pushbutton switch. Connect the positive wire from the PVS-5 to the other side of the switch. Route the ground wire from the PVS-5 through the slot in the washer and out the back of the housing. Next we make the rear battery connection by using a spring secured into the rear end cap. I used a spring from a 'D' cell battery holder and secured it into place with a 2-56 screw and nut. I also soldered the ground wire to the spring after I determined the length so that the cap would just come off and let the battery slide free. But use your ingenuity on this. Install the battery with the positive side pointing towards the front of the scope and put on the rear end cape. Press the button and viola, check for a working scope.

Finally (whew) install the front end cap and secure the battery housing to the main housing with a bead of silicon rubber along both sides of the battery housing. Smooth the silicone down so it looks like it was made like that. Let the silicon dry. Next, paint the housing whatever color you want. Again, I used flat satin black.

DO not point your scope at the sun or other really bright light source. Even though the scope has automatic gain control, a bright IR source could burn the MCP.

One reason for using the lens adaptor was so that a telephoto lens could be used or just a standard 35mm lens. Also, the 35mm eyepiece lens makes it nice for mounting to other devices like a camera (with a 80mm extension) with the threaded lens front. I have built maybe 14 of these and they are great scopes. Far better than the Russian stuff in terms of resolution and clarity. Below is the vendors for the MCP modules:

MWK Industries
1269 W. Pomona
Corona, CA 91720
Cost: $395 item number NIGTU2 (ask for Martin)

Meredith Instruments
P.O. Box 1724
5035 N. 55th Ave. #5
Glendale, AZ 85301

Have fun with it and let me know how it goes :-) (particularly if you get some foxy lady that likes nude moonbathing and you get some nice 8 x 11's :-) My e-mail is

And if you need an IR filter for that spotlight so you can use it to 'help out' the above project, here's a little something:

(From William J. Beaty)

The large amounts of IR plastic filter sheet are no longer available, but here's a hint.

Go to a theatrical lighting supplier and buy two filter gels, one for "congo blue" and one for primary red. Overlap them and you get black. However, these dyes are transparent to IR. Lay them between thin plexi for a big filter sheet. They aren't entirely black, you can see the sun through them. for darker filtering, overlap more sheets. The standard sheet is 18" x 24" (I think) and costs $3 to $5.

and (From John De Armond)

Edmund Scientific sells surplus sniperscope illuminator IR filters for about $20. This is a glass filter that can stand the heat of a large lamp.

6. Decoding IR Remote Controls

(From Juergen Putzger)

The origin of this posting was the question what to do with an old TV. I suggested to use the infrared remote control as an input keyboard for a microcontroller board and mentioned a piece of code I had written for the 8052 microcontroller. I was asked by some people to share my information about remote controls, so here it is:

There are at least two international standards which are used by remote controls to encode the commands, the RC5 and RECS 80 code. The RECS 80 code uses pulse length modulation. Each bit to be transmitted is encoded by a high level of the duration T followed by a low level of duration 2T representing a logical '0' or 3T representing a logical '1'.

  T 2T T 3T  T 2T
  _    _     _
 | |  | |   | |
_| |__| |___| |__
  0    1     0
Notice that a '1' takes more time to be transmitted than a '0'. The RC 5 code instead has a uniform duration of all bits. A transition in the middle of the time interval assigned to each bit encodes the logical value. A '0' is encoded by a high to low transition and a '1' by a low to high transition. Therefore we need additional transitions at the beginning of each bit to set the proper start level if a series of equal bits is sent. We don't need this additional transition if the next bit has a different value. This is also called a 'biphase' code.

 __    __       __    __
   |  |  |     |  |  |
   |__|  |_____|  |__|
   0     0     1     1
Instead of being fed direct into the IR emitter, most remote controls modulate a 20-30 kHz carrier with this signal. A logic one is represented by a burst of oscillations.

  0      1       0       1      0
The reason is, that you can use a filter tuned to the carrier frequency to distinguish the signal from noise in the ambient light. Fluorescent lamps are the main source of such noise. Photodiodes behind an optical filter which transmits infrared light but blocks visible light are used as detectors. The signal from the photodiode is fed through a filter tuned to the carrier fequency and then amplified. The amplified signal is demodulated just like the carrier is demodulated in any AM radio receiver.

    _|_  photodiode
    /_\                 demodulator
     |      |\
    _|_ ____| \_____| |__ __|\|___ ____            L and C form a
   |   |    | /     | |  |  |/|   |    signal      circuit resonant
   |   /    |/          _|_       |    out         to the carrier
  ===  \    amplifier   /_\      ===
   |C  / L               |        |
It can be a lot of pain to design a sensitive receiver that does'nt start to oscillate. It is also necessary to have some automatic gain control to avoid overload of the amplifier at close distance to the emitter. It is easier to use some integrated circuit that does all of the job. The best i have ever seen (and used) is the SFH505A manufactured by SIEMENS (no, I don't work for this company). It looks like one of this three legged voltage regulators and uses a single 5V supply. It incorporates an optical filter, the photodiode, a filter tuned to about 30 kHz , the amplifier with automatic gain control and the demodulator.

If you don't know which code your remote control is transmitting you can identify it by viewing the output of your receiver with an oscilloscope. The RECS 80 code uses high pulses of uniform length while the low pulses differ in length. If there are high and low pulses of two different lengths it might be RC5 code. Note that your receiver may invert the levels.

How are commands like volume control or channel selction encoded? In the case of the RC5 code there is an international standard. Every command is encoded by 14 bits. The first two bits S are startbits to allow the receiver to adjust the automatic gain control and to synchronize. Next a bit T follows, that toggles with every new keystroke. Next is the address A of the device which shall respond to the command. At last the command itself follows.

  | S | S | T | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C0 |
Some important addresses and commands:

Address:          Device:          Command:
  0               TV1              0...9    Numbers 0...9 (channel select)
  1               TV2              12       Standby
  5               VCR1             16       Master Volume +
  6               VCR2             17       Master Volume -
 17               Tuner            18       Brightness +
 18               Audio Tape       19       Brightness -
 20               CD Player        50       Fast rewind
                                   52       Fast run forward
                                   53       Play
                                   54       Stop
                                   55       Recording
There are integrated decoder circuits which have inputs to select the device address and parallel outputs activated by the commands. Since this is comp. robotics the devices you wish to control will have a microcontroller on board which can do all the decoding. Here is an input routine I have written for the 8052 microcontroller family to receive RC5 codes. My cousin has written a similar routine for the RECS80 code which i will try to make available also. Perhaps we can start a collection of such routines and archive them somewhere.

;  ---------==========----------==========---------=========---------
;         Interrupt Driven Receiving Routine for RC5 code
; written by Juergen Putzger (
;  ---------==========----------==========---------=========---------
INPUT   EQU     P3.2    ; Port3,Bit2 is used as input. The demodulated signal
                        ; with active low level is connected to this pin
LF      EQU     0AH     ; Linefeed
CR      EQU     0DH     ; Carriage return
SPC     EQU     20H     ; Space
RB0     EQU     000H    ; Select Register Bank 0
RB1     EQU     008H    ; Select Register Bank 1  ...poke to PSW to use
        DSEG            ; This is internal data memory
        ORG     20H     ; Bit adressable memory
FLAGS:  DS      1
CONTROL BIT     FLAGS.0  ; toggles with every new keystroke
NEW     BIT     FLAGS.1  ; Bit set when a new command has been received
COMMAND: DS     1       ; Received command byte
SUBAD:  DS      1       ; Device subaddress
BUFFER: DS      30      ; Buffer to store length of transmitted pulses
STACK:  DS      1       ; Stack begins here
        CSEG            ; Code begins here
         ORG     00H    ; Reset
         JMP     MAIN
         ORG     0003H  ; External Interrupt0
         JMP     RECEIVE
;  ---------==========----------==========---------=========---------
;                            Output routines
;        DonB4t forget to set up the serial port and Baud rate !
;  ---------==========----------==========---------=========---------
N_OUT:  ADD     A,#30H  ;Convert BCD number to ASCII
C_OUT:  JNB     TI,$    ;Wait until transmission completed.
        CLR     TI      ;Clear interrupt flag.
        MOV     SBUF,A  ;Write out character to serial port.

BIN2BCD:                ;Convert 8 bit value in Acc to 3 digit BCD
        MOV     B,#100
        DIV     AB
        CALL    N_OUT
        XCH     A,B
        MOV     B,#10
        DIV     AB
        CALL    N_OUT
        XCH     A,B
        CALL    N_OUT
;  ---------==========----------==========---------=========---------
;  Interrupt routine is entered by the first high to low transition
;  at Port3-Bit2. Stores the length of all pulses occuring at this
;  pin in buffer. Analyzes the timing of the startbits to calculate
;  a threshold between short and long pulses. This routine is
;  independent of CPU speed. The device address and command are
;  extracted from the bit stream. Two flags are set upon exit,
;  the control bit which toggles with every new keystroke and the
;  NEW bit indicating that a new command has been received.
;  ---------==========----------==========---------=========---------
         PUSH   PSW           ; save current registerset
         MOV    PSW,#RB1
         PUSH   ACC
         MOV    R0,#BUFFER
REC:     MOV    A,#0
REC0:    INC    A             ; Measure duration of low-level
         NOP                  ; Delay
         JZ     TIMEOUT       ; End of transmission if duration exeeds 256 counts
         JNB    INPUT,REC0
         MOV    @R0,A
         INC    R0
         MOV    A,#0
REC1:    INC    A             ; Measure duration of high-level
         NOP                  ; Delay
         JZ     TIMEOUT       ; End of transmission
         JB     INPUT,REC1
         MOV    @R0,A
         INC    R0
         JMP    REC
         MOV    A,BUFFER      ; calculate threshold between short and long pulses
         INC    R0            ; length of first low-pulse
         ADD    A,BUFFER+1    ; plus length of first high-pulse
         CLR    C
         RRC    A             ; divided by two
         MOV    R1,A
         CLR    C
         RRC    A             ; plus half of the time
         ADD    A,R1
         MOV    R5,A          ; yields threshold
         MOV    R0,#BUFFER
         MOV    R1,#1         ; initial value
         MOV    R2,#13        ; Number of bits to decode
         INC    R0
         CLR    C
         SUBB   A,R5          ; compare length with threshold
         MOV    A,#0
         CPL    C             ; short=1
         RLC    A
         JNZ    NOSKIP
         INC    R0            ; if short skip over next pulse
NOSKIP:  XRL    A,R1          ; new bit is calculated by XOR with previous bit
         MOV    R1,A          ; Store new bit
         RRC    A
         MOV    A,R3          ; Store new Bit in R3/R4 by rotating
         RLC    A
         MOV    R3,A
         MOV    A,R4
         RLC    A
         MOV    R4,A
         DJNZ   R2,DECODE
         MOV    A,R3
         ANL    A,#00111111B  ; extract command from R3
         MOV    COMMAND,A
         MOV    A,R3
         RLC    A             ; do some rotating to extract
         XCH    A,R4
         RLC    A             ;device address
         XCH    A,R4
         RLC    A
         XCH    A,R4
         RLC    A
         CLR    CONTROL
         JNB    ACC.5,TZ      ; Check control bit
         SETB   CONTROL
TZ:      ANL    A,#00011111B  ; mask device address
         MOV    SUBAD,A
         POP    ACC           ; Restore old registerset
         POP    PSW
         SETB   NEW           ; Set flag to indicate the new command

;  ---------==========----------==========---------=========---------
;  Main routine. Program execution starts here. Don't forget to add
;  code to initialize the serial port and Baud rate if your monitor
;  program doesn't do that for you. The Main loop waits until a command
;  has been received. Then the control bit, subaddress and command byte
;  are printed separated by spaces. Leading zeroes are not suppressed.
;  When a standby command (12) has been received, the main loop is
;  terminated and the program returns to the monitor.
;  ---------==========----------==========---------=========---------

         MOV    PSW,#RB0      ; Select register bank 0
         MOV    SP,STACK
         SETB   EX0           ; Enable external Interrupt0
         CLR    IT0           ; triggered by a high to low transition
         SETB   EA
         CLR    NEW
LOOP:    JNB    NEW,LOOP      ; Wait until a command has been received
         MOV    A,#CR
         CALL   C_OUT         ; Ouput carriage return and linefeed
         MOV    A,#LF
         CALL   C_OUT
         MOV    A,FLAGS
         ANL    A,#00000001B
         CALL   BIN2BCD       ; Output control Bit
         MOV    A,#SPC
         CALL   C_OUT
         MOV    A,SUBAD
         CALL   BIN2BCD       ; Output subaddress
         MOV    A,#SPC
         CALL   C_OUT
         MOV    A,COMMAND
         CALL   BIN2BCD       ; Output command
         MOV    A,COMMAND
         CLR    C
         SUBB   A,#0CH        ; compare for standby command
         CLR    NEW
         JNZ    LOOP          ; go on receiving
         CLR    EX0           ; stop receiving
         CLR    EA            ; and
         JMP    8000H         ; return to monitor which has its entry point at 8000H

Also see

7. IR 'slotted switch' sensor

(From Paul Hitchcock)

There is a type of detector known as a "slotted switch" that consists of a phototransistor/LED pair mounted on a solid frame with a small air gap between the two elements. A typical circuit might be:

               o +5v     o +5v
               |         |
               |         |
               \         \
    220 ohms   /         / 4.7K
               \         \
               /         /
               |         |
               |         +-------&gt; Vout
              _|_        /
              \ /      |/
             -----     |\ NPN
               |         \
               |          |
               |          |
               |          |
              GND        GND

                | air gap |
When the air gap is unobstructed, the transistor saturates, pulling Vout to ground; when the gap is blocked, the transistor cuts off and Vout is +5 volts.

Please see document for document author. | [mailto]. The most recent version is available on the WWW server [Copyright] [Disclaimer]