« Feb. 8th readings | Main | Dano presents J2ME »
February 16, 2005
problem child
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : dimitri *
'* Notice : Copyright (c) 2005 [set under view...options] *
'* : All Rights Reserved *
'* Date : 2/14/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
i var byte
' ds var byte
' ns var byte
' Serial out to PC is on pin RC6
' serial in from PC is on pin RC7
' serial out to Lantronix device is on RD1
' serial in from Lantronix device is on RD0
' Lantronix device DTR pin is on RD2
' note: Lantronix device must have DisconnectMode set to 0x80
' in order to disconnect using DTR pin.
' an analog sensor is on pin RA0
' pins RB0 through RB7 have LEDs on them.
' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
' variables and constants for the serial port:
dataByte var word
'dataWord var word
'xVarbyte var byte
'tx var portc.6
'rx var portc.7
xportTx var portd.1
xportRx var portd.0
xportDTR var portd.2
inv9600 con 16468 ' baudmode for serin2 and serout2: 9600 8-N-1 inverted
non9600 con 84 ' baudmode for serin2 and serout2: 9600 8-N-1 non-inverted
' general-purpose counter:i var byte
'vars for accelerometer
xVar var word
'txpin var portc.6
'variables for ADC:
ADCvar var word ' Create variable to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
TRISB = %00000000 ' set all the pins of PORTB to output
' blink an LED on startup:
high portb.0
pause 1000
low portb.0
' take DTR high so Xport doesn't disconnect when we first connect:
HIGH xportDTR
Pause 1000 ' Wait a second at startup
main:
'adcin 0, xVar
serin2 xportRx, inv9600,10, keepgoing, [DEC4 dataByte]
high portb.3
low portb.4
if dataByte > 500 then
high portb.0
high portb.1
high portb.2
low portb.5
low portb.6
low portb.7
endif
high portb.4
low portb.3
if dataByte > 500 then
high portb.5
high portb.6
high portb.7
low portb.0
low portb.1
low portb.2
endif
'serout2 xportTx, non9600, [DEC4 dataByte]
' if(databyte = N) then
' high portb.0
' else
' low portb.0
' endif
' if (dataByte > xVar) then
' serout2 xportTx, non9600, ["D"]
' endif
' if (dataByte < xVar) then
' serout2 xportTx, non9600, ["N"]
' endif
goto main
keepgoing:
goto main
Posted by dimitri at February 16, 2005 03:55 PM