Trying to post source code into WordPress post

'********************************************************************
'* Name : UNTITLED.BAS *
'* Author : Sean Harmon *
'* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 5/19/2011 *
'* Version : 1.0 *
'* Notes : Quick Infrared scanner using IR demodulator connected *
'* to port assigned to IRPin. *
'* PULSIN measures the pulse width of the IR-LED *
'* : *
'********************************************************************
DEFINE OSC 20 '// Define Oscillator @ 4mHz
include "ansi.inc"

ADCON1 =%00000111

'---------------------------------------------------------------------
'---------- Define LCD Options ---------------------------------------
'---------------------------------------------------------------------
Define LCD_DREG PORTD '// Define the data port
define LCD_DBIT 0 '// Select port bit [0-lower or 4-upper]
define LCD_RSREG PORTC '// Select RS port
DEFINE LCD_RSBIT 4 '// Set RS bit (port number)
define LCD_EREG PORTC '// Set E port
define LCD_EBIT 5 '// Set E bit
define LCD_BITS 4 '// 4 or 8 bit LCD

'---------------------------------------------------------------------
'----------[Define HSEROUT Options]-----------------------------------
'---------------------------------------------------------------------
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
'DEFINE HSER_SPBRG 25 '//commented out to get 9600baud working

'DEFINE PULSIN_MAX 5000 '// MAX wait time for pulsin
TRISB.4 = 1 '// Set IR pin as Input

trx_pin VAR PORTA.0
IRPin Var PORTB.4 '// Set IR input pin

mode Var word '// Storage for serial mode
baud VAR byte
state var byte
Index VAR byte
IR_Size Var byte
IR_PULSE VAR WORD(13) '// 13-bytes. 8 data ; 5 address

mode = 16468
index = 0

Pause 500 'allow LCD to startup
@ ClearScr '//Clear Screen
hserout [10,13,"-----[IR Scanner]-----",13,10]
serout2 trx_pin,49236, [" IR Scanner "]
LCDout $FE, 1, " IR Scanner"

main:
pulsin IrPin,0,IR_Pulse(0)
if IR_Pulse(0) < 30 Then goto main
FOR Index = 1 TO 15
PULSIN IRPin,0,IR_PULSE[Index]
if Ir_Pulse[index] < 40 Then
IR_Size = Index
goto PrintIR
endif
NEXT Index

printIR:
lcdout $FE, 1
hserout [10,13]
for Index = 0 to (IR_size - 1)
serout2 trx_pin, 84, [IR_Pulse(index), " "]
hserout [DEC ir_pulse(index), " "]
lcdout #IR_pulse(index), " "
pause 10
Next Index
pause 100
goto main

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s