Infra red receiver commands trigger

Important notice:

This electronic project is directly connected to the mains, extreme caution should be taken when building and connecting this project to the mains supply. The result could be fatal. If you have any doubt about building/using the project on this page – stop now. Equipment can be bought off the shelf for the same purpose as the project here.

I AM NOT RESPONSIBLE FOR YOUR SAFETY

 

About

This device switches mains and/or non-direct mains appliances on and off via an infrared remote control. The schematics control 3 appliances, but can be expanded to 8.

 

Notes about the project

I’ve taken precautions for safety: each mains output is fused, enclosed in a grounded metal box, and uses opto isolators to prevent back voltage. Zero crossing detection helps avoid interference. Always double-check your build before connecting to mains.

 

Building it

Part 1.

The circuit uses a PIC16F84 which receives infrared via a module. It responds to predefined IR codes. It currently doesn’t learn from new remotes but works with compatible or programmable ones. A recognized signal switches one or more outputs.

Powered via internal USB (stays powered when PC is off). The test circuit responds to a Goodman's remote and shows IR data on port B.

The circuit responds to the Goodman's IR remote. Remote
Test Circuit
The ASM and HEX files for this code are here.
Photos of the infrared receiver (taken with a 2006 phone!):
Top view Better view of the receiver
Top view Receiver close-up

The receiver is made by Sony. The 4 LEDs are connected to RA1–RA4. RA0 is input. The signal from the IR receiver is clean enough for direct connection to the PIC.

Development used a second PIC to duplicate and send codes for fast testing. Here's a photo during development:

Development stage

Note: RA4 operates as a drain, making it ideal for IPAC "insert coin" input. Not all IR receivers behave the same — Goodman’s had lower signal levels requiring amplification. I stuck with the Sony one.

Final PIC circuit This is my final build of the PIC circuit.

Part 2: Mains Switching

Final caution – this section involves mains power. Risk of injury or death.

This section switches mains appliances using opto-triacs. The software controls 3 channels, but can be expanded.

Mains switching BTA26 pinouts MOC3041 pinouts
Mains circuit BTA26 pinout MOC3041 pinout
Multiple switching modules

Initially planned 3 units but built only 1 for the marquee light.

A BTA26 triac is probably overkill for this project. Rated at 600v @ 25 amps, your likly not going to be switching such a heavy load. I have used BTA16's in the past in the same circuit. Probably much more suitable.

Rated at 600V @ 16 amps.

Installed in metal box Fitted into a metal box and safely grounded.

The PIC and mains switching sides are kept separate for safety.

Here’s the final full circuit:

Final complete circuit

Don't forget the PIC’s power connections. If everything responds to IR, you can try the final code for full output support.

Use the remote shown at the top or a universal one. Press 1 to trigger RA1. Key 5 switches it off. Keys 2–4 toggle other outputs. Key 8 switches off another latch.

I power mine from an internal USB header.

 

If you have Proteus by Labcenter, you should be able to load in this project and run it in that environment. All my work is here.

How the receiver ASM code works

1. Entry & Initialization


; ORG 0 vector
entrypoint    goto initialise

; ORG 11 — set up ports & registers
initialise
    clrw                ; clear W
    movwf PORTA         ; zero PORTA
    movwf PORTB         ; zero PORTB
    bsf   STATUS,RP0    ; switch to Bank1
    movlw b'00001'      ; RA0 input, RA1–RA4 outputs
    movwf PORTA
    clrf  TRISB         ; PORTB all outputs
    bcf   STATUS,RP0    ; back to Bank0
    clrw
    movwf fish          ; clear scratch register
    goto  star
    

2. Reading two halves of the IR code


star     clrf PORTB    ; clear shift register
start    movlw d'2'    ; bigloop = 2 bytes to read
bigloop  
  ; wait for start bit (line idle high → low)
  btfsc PORTA,0
  goto  start
  ; center‑point delay, then read 8 bits:
loopstart
  movlw d'8'
  movwf counter
mainloop
  bcf   PORTB,7          ; default bit = 0
  btfsc PORTA,0          ; if IR line high
    bsf PORTB,7          ;   set bit = 1
  rrf   PORTB            ; shift into LSB
  call  ms               ; ~2.3 ms delay
  decfsz counter
  goto  mainloop
  decfsz bigloop
  goto setcode1 / setcode2
    

3. Storing & validating the two bytes


setcode1  movwf code1   ; first byte
         goto doubleme

setcode2  movwf code2   ; second byte

; compare code1 vs code2
clrw
addwf code1,0
subwf code2
btfss STATUS,Z          ; if not equal
  goto start            ;   ignore – wait next code
    

4. Decoding commands


; for each known pattern, test code1:
clrw
addwf code1,0
movwf fish
movlw b'11111010'       ; “marquee on”
subwf fish
btfsc STATUS,Z
  call marquee_on

; …repeat for marquee off, monitor on/off, PC power, coin…
    

5. Output subroutines


pcpow    bsf PORTA,3    ; RA3 high → PC power toggle
         call ms 6x      ; longer press
         bcf PORTA,3
         return

coin     bsf PORTA,4    ; RA4 “coin insert”
         call ms x4
         bcf PORTA,4
         return

; …and similarly for marquee & monitor routines…
    

6. Delay helper (`ms`)


ms       movwf msloop
outerloop
  movlw d'32'
  movwf inloop
innerloop
  decfsz inloop
  goto innerloop
  decfsz msloop
  goto outerloop
  return
    

← Back to Projects