Urgent help with code
I am having some problems with the 433 MHz receiver. Let me first give you a rundown of my project. I am building an avalanche search bot. The victim of the avalanche has a separate board with the transmittter that is constantly transmitting a signal. My robot has a receiver that is made directional, so only a signal that is pretty close to head on willl be received. I am trying to make it wait for a signal for 1 second. If it doesn't receive it I want it to turn a few degrees clockwise. The problem with this is I can't get the waiting for 1 second part to work. Here is a small snippet of the code:
x VAR Word
y VAR Word
counter VAR Word
DO
LOW 1 'turn led off
SERIN 0, 16468,1000,Left, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
HIGH 1 'turn led on
DEBUG ? x
DEBUG ? y
LOOP
END
Left:
FOR counter = 1 TO 100 ' turn a few degrees
PULSOUT 12, 650
PULSOUT 13, 850
NEXT
RETURN
The way I test it is by turning of the transmitter and seeing if it moves. However nothing happens, but when I plug it in, it starts to receive again.
I would really appreciate any help I can get.
x VAR Word
y VAR Word
counter VAR Word
DO
LOW 1 'turn led off
SERIN 0, 16468,1000,Left, [noparse][[/noparse]WAIT("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
HIGH 1 'turn led on
DEBUG ? x
DEBUG ? y
LOOP
END
Left:
FOR counter = 1 TO 100 ' turn a few degrees
PULSOUT 12, 650
PULSOUT 13, 850
NEXT
RETURN
The way I test it is by turning of the transmitter and seeing if it moves. However nothing happens, but when I plug it in, it starts to receive again.
I would really appreciate any help I can get.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
It should be waiting for one second when no signal comes goes down to the subroutine Left and execute that. But it is not doing that.
I am beginning to think that you can't use the wait command and the timeout command in the same line.· I don't see them doing that anywhere in the help file...
ORIGINAL MESSAGE:
The only thing I see different between yours and the help files is 2 things... One is try adding spaces, although I don't think that will fix it... Two, try changing the 'RETURN' line to a 'GOTO' and add something above your main program.... (See below)
x VAR Word
y VAR Word
counter VAR Word
Main:
DO
LOW 1 'turn led off
SERIN 0, 16468, 1000, Left, [noparse][[/noparse]WAIT ("!"), x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE]
HIGH 1 'turn led on
DEBUG ? x
DEBUG ? y
LOOP
END
Left:
FOR counter = 1 TO 100 ' turn a few degrees
PULSOUT 12, 650
PULSOUT 13, 850
NEXT
GOTO Main
Post Edited (Joms) : 3/4/2009 3:11:33 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen