XTAL = 20 LCD_DTPIN = PORTD.4 LCD_RSPIN = PORTE.0 LCD_ENPIN = PORTE.1 LCD_INTERFACE = 4 ' 4-bit Interface LCD_LINES = 2 LCD_TYPE = 0 SCL_PIN = PORTC.3 SDA_PIN = PORTC.4 SERIAL_BAUD = 19200 RSOUT_PIN = PORTC.6 RSOUT_MODE = TRUE RSOUT_PACE = 1 RSIN_PIN = PORTC.7 RSIN_MODE = TRUE HSERIAL_BAUD = 19200 ' Set baud rate to 9600 HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive HSERIAL_TXSTA = %00100100 ' Enable transmit and asynchronous mode HSERIAL_CLEAR = ON ' Enable Error clearing on received characters KEYPAD_PORT = PORTB CCP1_PIN = PORTC.2 CCP2_PIN = PORTC.1 Symbol T300 = 3313 NO_LIST Symbol N300 = 3313 + $4000 NO_LIST Symbol T600 = 1646 NO_LIST Symbol N600 = 1646 + $4000 NO_LIST Symbol T1200 = 813 NO_LIST Symbol N1200 = 813 + $4000 NO_LIST Symbol T2400 = 396 NO_LIST Symbol N2400 = 396 + $4000 NO_LIST Symbol T4800 = 188 NO_LIST Symbol N4800 = 188 + $4000 NO_LIST Symbol T9600 = 84 NO_LIST Symbol N9600 = 84 + $4000 NO_LIST Symbol OT2400 = 396 + $8000 NO_LIST ' Open True Symbol OT1200 = 813 + $8000 NO_LIST ' Open True Symbol OT9600 = 84 + $8000 NO_LIST ' Open True Symbol OT300 = 3313 + $8000 NO_LIST ' Open True Symbol ON2400 = 396 + $4000 + $8000 NO_LIST ' Open Inverted Symbol ON1200 = 813 + $4000 + $8000 NO_LIST ' Open Inverted Symbol ON9600 = 84 + $4000 + $8000 NO_LIST ' Open Inverted Symbol ON300 = 3313 + $4000 + $8000 NO_LIST ' Open Inverted Symbol HOME = 1 NO_LIST Symbol BELL = 7 NO_LIST Symbol BKSP = 8 NO_LIST Symbol TAB = 9 NO_LIST Symbol CR = 13 NO_LIST ALL_DIGITAL = TRUE ' Set PORTA and PORTE to all digital SYMBOL IRTRAN=PORTC.0 INPUT IRTRAN DIM BufferPos as BYTE DIM BitLength[128] as WORD DIM BitState[128] as BYTE DIM IRCOUNT as WORD DIM IROLDSTATE as BYTE DIM IRNEWSTATE as BYTE DIM BufCounter as BYTE DIM TIMER1 AS TMR1L.WORD device 18f452 DELAYMS 1000 RSOUT "I AM AWAKE",13,10 CheckStart: IRCOUNT=0 IROLDSTATE=0 IRNEWSTATE=0 BufferPos=1 OUTPUT PORTD.0 LOW PORTD.0 INPUT IRTRAN WHILE IRTRAN=1 : WEND HIGH PORTD.0 CLEAR TIMER1 T1CON=%00000001 ReceiveLoop: INPUT IRTRAN WHILE IRTRAN=1 IF TIMER1>60000 THEN GOTO ReceiveComplete WEND T1CON=%00000000 BitLength[BufferPos]=TIMER1 CLEAR TIMER1 T1CON=%00000001 BitState[BufferPos]=0 INC BufferPos INPUT IRTRAN WHILE IRTRAN=0 IF TIMER1>60000 THEN GOTO ReceiveComplete WEND T1CON=%00000000 BitLength[BufferPos]=TIMER1 CLEAR TIMER1 T1CON=%00000001 BitState[BufferPos]=1 INC BufferPos If BufferPos<50 THEN GOTO ReceiveLoop ReceiveComplete: OUTPUT PORTD.1 OUTPUT PORTD.2 HIGH PORTD.1 LOW PORTD.2 FOR BufCOUNTER=1 TO BufferPos-1 RSOUT HEX BitState[BufCOUNTER],",", DEC BitLength[BufCOUNTER],13,10 NEXT BufCOUNTER RSOUT "IR Signal End",13,10 DELAYMS 5000 HIGH PORTD.2 DELAYMS 5000 HIGH PORTD.4 RSOUT "Sending IR Signal..." OUTPUT PORTC.2 OUTPUT PORTC.1 LOW PORTC.2 LOW PORTC.1 ' HPWM 1,127,3686 PR2=137 CCPR1L=68 TRISC.2=0 CCP1CON=%00001100 T2CON=%00000100 FOR BufCOUNTER=1 TO BufferPos-1 BitLength[BufCounter]=(BitLength[BufCounter]/5) NEXT BufCOUNTER DELAYMS 200 FOR BufCOUNTER=1 TO BufferPos-1 If BitState[BufCounter]=0 THEN LOW PORTC.1 : ELSE HIGH PORTC.1 DELAYUS BitLength[BufCounter] NEXT BufCOUNTER LOW PORTC.1 LOW PORTD.0 LOW PORTD.1 LOW PORTD.2 LOW PORTD.4 RSOUT "Sent.",13,10 GOTO CheckStart