'CPU = 16F84A 'MHZ = 4 'CONFIG 16383 '**************************************************************** '* Name : IR675.BAS * '* Author : Craig S Gardner, Modified by Jonathan Peakall to * '* : allow baud rate selection. * '* Notice : Copyright (c) 2003 * '* : ALL Rights Reserved * '* Date : 10/3/2003 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** @ DEVICE INTRC_OSC, MCLR_off, PROTECT_OFF, WDT_OFF CMCON = 7 ' Comparators OFF ANSEL = 0 ' A/D OFF -- Port pins all digital TRISIO = %010000 ' All I/O but GPIO3 = outputs GPIO = %000000 ' All 0 on boot sBaud var byte IRpulse_length var word(13) xx var Byte Command Var Byte Device Var Byte input gpio.3 'clear pause 500 sbaud = 2 if gpio.3 = 1 then sBaud = 2 endif if gpio.3 = 0 then sBaud = 0 endif Getstartbits: PuLSIN GPIO.1,0,IRpulse_length(0) if IRpulse_length(0) < 200 then goto getstartbits Endif for xx=1 to 12 pulsin GPIO.1,0,IRpulse_length(xx) next xx displaybits: if IRpulse_length(1) < 100 then Command.bit0 = 0 Else Command.bit0 = 1 endif if IRpulse_length(2) < 100 then Command.bit1 = 0 Else Command.bit1 = 1 endif if IRpulse_length(3) < 100 then Command.bit2 = 0 Else Command.bit2 = 1 endif if IRpulse_length(4) < 100 then Command.bit3 = 0 Else Command.bit3 = 1 endif if IRpulse_length(5) < 100 then Command.bit4 = 0 Else Command.bit4 = 1 endif if IRpulse_length(6) < 100 then Command.bit5 = 0 Else Command.bit5 = 1 endif if IRpulse_length(7) < 100 then Command.bit6 = 0 Else Command.bit6 = 1 endif Command.bit7 = 0 Command = Command + 1 If Command = 10 then Command = 0 Endif if IRpulse_length(8) < 100 then Device.bit0 = 0 Else Device.bit0 = 1 endif if IRpulse_length(9) < 100 then Device.bit1 = 0 Else Device.bit1 = 1 endif if IRpulse_length(10) < 100 then Device.bit2 = 0 Else Device.bit2 = 1 endif if IRpulse_length(11) < 100 then Device.bit3 = 0 Else Device.bit3 = 1 endif 'Device.bit1 = 0 SEROUT GPIO.0,sbaud,[Device,Command] pause 100 goto Getstartbits