:XONOFF.BA House control using X10 :Revised: 1/13/04 :(C) 05/01/2003 R. H. Pigford :Take House Code and Unit no input5:Then take ON/OFF inputo:Then execute command string strings to FireCrackerw:#:(E$(27):I$E$"p":J$E$"q"22000 :reset FireCracker4d:I$"===== XONOFF.BA (c) R. H. Pigford ===="J$;:@280,I$"X-10 with Firecracker";:@308,"ESC"J$" to Quit";[s@40,"";:"HOME Code (A-P) ";HC${tHC$"P" HC$"A" :115v@80,"";:"UNIT number (1-16)";HN$x (HN$)16 (HN$)1 : 118|@120,"";:"N = on, F = off ";HA$~ HA$"N" HA$"F" :1242̀AD$HC$HN$HA$:@186,AD$X͂@160,"Hit ENTER to Execute --->"{͆:PRINT@200,"Hit ESC to Quit"A$: A$"" 200 A$(13) 250A$(27)ͺSELECT$AD$:1000:AD$"": 100:=======================:B1(LOOKUP$,(SELECT$,1))8 B10 "Error":@:`:Get ACTion byte from endh:~ACT$(SELECT$,1)::Calculate Byte 1 (B1):B1(B11) 16 ACT$"D" 1200 ACT$"B" 1250$NUM((SELECT$,(SELECT$)1))1'. NUM 7 B1B14/3:L4:Calculate Byte 2 (B2)T5:j8B2(NUM 1) 16BB2B2 ((NUM 2) 4)LB2B2 ((NUM 4) 16)V ACT$"F" B2B2 32[:\:Now go send the command]:` 1300 : Skip DIM & BRIGHTe:=аB2 152 : DIM Command. Set B2\к 1300 : Go send commandB2 136 : BRIGHT Command. Set B2 : :Send 5 Bytes below as follows: :2 Header, 2 Data, 1 Footer :TX213 : First Header Byte  15001(TX170 : Second Header Byte<2 1500^<TXB1 : First Data ByteiF 1500PTXB2 : Second Data ByteZ 1500dTX173 : Footer Byten 1500o:p:========================q:End of Subroutine 1#r:========================)x1:Z:=================================: Sub 2 - Write single byte (TX): (called by Sub 1):: Write TX to FireCracker using: RTS and DTR signals, MSB first!:=================================):J SHOWTX$"Y" 1501 : 1510_ X 7 0 1 TX (2X) "1"; : "0"; X " ":P1(186) : Read PortB of 8155P1P1 247: Clear BIT 3 186, P1 : Select RS-232 Port:7:Loop through bits starting withW:the Most Significant bit_:t X 7 0 1 TX (2X) 1600:: Bit is a zero - send it out: 186, P1 128 :Send a "0"" 186, P1 127 :Back to idle*, 1620 : Skip sending a "1"21:T2:Bit is a one - send it out\3:@ 186, P1 64 : Send a "1"J 186, P1 191 : Back to idleO:T XX:Y:==========================Z:End of Subroutine 2[:=========================="^*ֆ:S:=================================u: Sub 3 - FireCracker Reset}:: Call this routine first!:=================================:P1(186) : Read PortB of 8155P1P1 247: Clear BIT 3: 186, P1 : Select RS-232 PortB:g: Set both RTS and DTR to zeroo: 186, P1 128 :Set RTS low 186, P1 64 :Set DTR low X1 10: X:Small Delay:: Set both RTS and DTR to one :0  186, P1 63 :Back to idle8:^: Set LOOKUP variable for laterf:LOOKUP$"MNOPCDABEFGHKLIJ"::=========================:End of Subroutine 3:========================= ٸ :"*** Communications Error ***" $٠: