| '**************************************************************** '* Name : Receive.BAS * '* Author : Jan Kordylewski* '* Notice : Copyright (c) 2004 freely distributable * '* : All Rights Reserved * '* Date : 12/12/2004 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** DEFINE OSC 20 DEFINE HSER_RXSTA 90h ' enable the receive register ' Define ADCIN parameters ADCvar VAR WORD ' Create variable to store result output portd.2 TRISA = %11111111 ' Set PORTA to all input portd.2 = 1 hserout [$90, $3,counter] serout2 portd.1, 16468, ["hello", 10, 13] main: ADCIN 0, ADCvar ' Read channel 0 to adval |
|
|
if ((portc.1 = 1) and (portc.2 = 1)) then hserout [$90, $3,$0F] hserout [$90, $2,$7F] if hit = 0 then hit = 1 endif 'portd.2 = 0 'pause 1000 'portd.2 = 1 serout2 portd.1, 16468, ["both", 10, 13] endif if ((portc.1 = 1) and (portc.2 = 0)) then serout2 portd.1, 16468, ["one", 10, 13] target = 40 'if counter > 30 then 'counter = counter - 1 'endif 'hserout [$90, $3,counter] 'portd.2 = 1 'hserout [$90, $2,$0] ELSE if ((portc.1 = 0) and (portc.2 = 0)) then Target = 127 hserout [$90, $2,$0] 'portd.2 = 1 endif endIF if counter < target then change = 2 endif if counter > target then change = -2 endif If (counter != target) then 'serout2 portd.1, 16468, ["neither", 10, 13] serout2 portd.1, 16468, ["my counter=",DEC counter, 10, 13] 'portd.2 = 1 'hserout [$90, $2,$0] counter = counter + change hserout [$90, $3,counter] pause 100 endIF if hit > 0 then portd.2 = 0 hit = hit +1 if hit > 1000 then hit = 0 portd.2 = 1 endif endif GoTo main ' Do it forever |
||