Receiver in an outlet box Picaxe Basic Program

Declarations and Data

#rem  Hanging lamp.bas This is the single outlet in the wood box

Use 9200N power supply 

Use with 7-position rotary transmitter CCW position

John Saunders 1/5/2015 Added phone jack output for LED current source ; phone jack 5V

11/28/2021 Note that the eggs are no longer connected to this unit. The LED driver is retired.

#endrem


#picaxe 08M2


'Output Ports

symbol Relay        = C.1

symbol Eggs         = C.2


'Input ports

symbol Rcvr_In     = C.4


'Variables

symbol Lamp_on     = bit0

symbol Eggs_on     = bit1

symbol Rcvr_Val    = b1

Init and  Main

init:

SETFREQ m8

LOW Relay

LET Lamp_on   = 0                      

SETINT  %00001000,%00001000    'Interrupt when C,3 high


main:

IF Lamp_On = 1 THEN

    HIGH Relay

ELSE

    LOW Relay

ENDIF     

IF Eggs_On = 1 THEN

    HIGH Eggs

ELSE

    LOW Eggs

ENDIF     

GOTO main

Interrupt

Interrupt:

PAUSE 10    'There is a 10 ms gap before the code to allow the serin to execute

LET Rcvr_Val = "Z"

SERIN [100,NoAscii],Rcvr_In,N2400_8,("14L1776"),Rcvr_Val

IF Rcvr_Val = "C" THEN

    LET Lamp_on = 0

ENDIF

IF Rcvr_Val = "I" THEN

    LET Lamp_on = 1

ENDIF

IF Rcvr_Val = "9" THEN

    LET Eggs_on = 0

ENDIF

IF Rcvr_Val = "d" THEN

    LET Eggs_on = 1

ENDIF

PAUSE 300

NoAscii:

SETINT  %00001000,%00001000    'Interrupt when C,3 high

RETURN