Here's the code to activate a loop that incraments the variable x by one each time then stops after x = 4. It's activated when a message has been sent from the blue smirf to the LCD through the pic. My partner precceeds all messages with a capital A to activate the serin command.
INCLUDE "modedefs.bas"
DEFINE OSC 20
INPUTDATA var byte
X VAR BYTE
X = 0
MAIN:
PORTB.5 = 0
SEROUT PORTB.1,T9600,[1]
WAITLOOP:
SERIN PORTA.1,T9600,[inputdata]
if inputdata <> "A" then goto waitloop
LOOP:
IF (X<4) THEN
HIGH PORTB.5
PAUSE 2
LOW PORTB.2
PAUSE 2
X = X+1
GOTO LOOP
endif
goto MAIN
This is a very simular code that activates the noise alert pulses constantly when the whearer of our device goes out of range then turns off when it comes back in range. It's activated by recieving a low at the input pin.
DEFINE OSC 20
TRISB.5 = 0
TRISB.4 = 1
X VAR BYTE
X = 0
START:
PORTB.5 = 0
IF PORTB.4 = 1 THEN GOTO START
IF PORTB.4 = 0 THEN GOTO LOOP
LOOP:
HIGH PORTB.5
PAUSE 2
LOW PORTB.5
Pause 2
IF PORTB.4 = 1 THEN GOTO START
GOTO LOOP
end
Bookmarks