by dshinsel » Mon Apr 10, 2006 10:37 pm
            
            
                    
                by dshinsel
Mon Apr 10, 2006 10:37 pm
            
            
            I use a bluetooth module (bluesmirf) connected to RX, TX, but you might be able to hook up serial directly (I have not tried it), or use a MAX232 chip to leve-shift.
The test code then looks like this (put in the begining of Main):
' Read Max Ultrasonic sensor
	US_Range = AD(2)
' DEBUG - test sensor:
	TxOut = " "
	ETX 9600, TxOut
	TxOut = "U"
	ETX 9600, TxOut
	TxOut = "S"
	ETX 9600, TxOut
	TxOut = "="
	ETX 9600, TxOut
	PrintByteVal = US_Range
	GOSUB PrintByte
... Normal processing continues here...
===============================================
At the bottom of the file, I added this subroutine:
===============================================
' Print 8 bit byte
' PrintByteVal passed in as value to print
PrintByte:
	
	' Print Low Byte	
	Temp = PrintByteVal >> 4
	Temp = Temp AND &H0F
	IF Temp > 9 THEN
		Temp = Temp + 55
	ELSE
		Temp = Temp + 48
	ENDIF
	ETX 9600, Temp
	Temp = PrintByteVal AND &H0F
	IF Temp > 9 THEN
		Temp = Temp + 55
	ELSE
		Temp = Temp + 48
	ENDIF
	ETX 9600, Temp
RETURN
            I use a bluetooth module (bluesmirf) connected to RX, TX, but you might be able to hook up serial directly (I have not tried it), or use a MAX232 chip to leve-shift.
The test code then looks like this (put in the begining of Main):
' Read Max Ultrasonic sensor
	US_Range = AD(2)
' DEBUG - test sensor:
	TxOut = " "
	ETX 9600, TxOut
	TxOut = "U"
	ETX 9600, TxOut
	TxOut = "S"
	ETX 9600, TxOut
	TxOut = "="
	ETX 9600, TxOut
	PrintByteVal = US_Range
	GOSUB PrintByte
... Normal processing continues here...
===============================================
At the bottom of the file, I added this subroutine:
===============================================
' Print 8 bit byte
' PrintByteVal passed in as value to print
PrintByte:
	
	' Print Low Byte	
	Temp = PrintByteVal >> 4
	Temp = Temp AND &H0F
	IF Temp > 9 THEN
		Temp = Temp + 55
	ELSE
		Temp = Temp + 48
	ENDIF
	ETX 9600, Temp
	Temp = PrintByteVal AND &H0F
	IF Temp > 9 THEN
		Temp = Temp + 55
	ELSE
		Temp = Temp + 48
	ENDIF
	ETX 9600, Temp
RETURN