Hello Andy,


Andy>>So looking at this example I have an serial ascii string being watched for by the pic and when the pic sees the N the code goes to the turnonroutine sub routine for 1 second.<

Lets look a little closer, to make *sure* you understand the statement ok?

SERIN portx,N2400,[“ASCII”],Var,

This statement says the following. The Chip will be in receive mode until it receives some kind of ASCII charactors. In this case (above) the Var will recieve the Charactor following the Ascii string "ASCII"

if your transmitter transmits "ASCII5" Var will have the value "5" in it.

====================================

Another example...

SERIN portx,N2400,[“Hello”],Var

Var will recieve the next charactor after "Hello".


If your transmitter transmits "Hellow", Var will have the value of "w" in it.


(look closely at this next example and notice capitalization ok?)

if your transmitter transmits "hellow" Var will never have a value in it, and your SERIN will continue to receive data until it sees the string "Hello".

===================================

Andy >>Is it correct to say then, if I serially send the alphabet in uppercase A-Z I can switch the light on for a longerstring of letters say MNO, so the light comes on only when all three characters have been sent and in the right order.<<

Yes Andy that is correct.

Andy>>NMO OMN etc should not gosub to turnonroutine MNO should.<<

That is correct. It is also CASE sensitive! so MNO is NOT equal to mno.


So if thats what I want to do, will this code be ok:


Andy >>
Var="MNO";
Loop:
SERIN portx,N2400,[“ASCII”],Var,
if Var<>"MNO" Gosub turnonroutine.
goto Loop
<<

Well, you are very close... Var will NOT have MNO in it. Look at my example above where I gave "hellow" and "hello5"

Lets rewrite it a little ok??

Lets let the transmitter send "MNOY"

Loop:
Var="N";
SERIN portx,N2400,[“ASCII”],Var,
if Var=="Y" Gosub turnonroutine. 'Var Y=yes! go to subroutine!
goto Loop


Andy>>
turnonroutine:
'Var="N" Also why do I need this 'N' here?
PortX=1 'turn on that light
pause 1000 'pause 1 second
Portx=0 'turn if off
return
<<

Ok, I switched the Var=n to the main part instead...You want to make DOUBLEY sure the Var is not ALWAYS equal to "Y"!
also, you may want to see that light blink don't you??? if so, you need a pause "someplace" that is long enough to see the light in the off position. So you can add a "Pause 100" after you turn off the port.

Andy>>Not sure how many output bits are left after connecting the PIC to a serial port, I also eventually want to send the pic another code to see if the PIC is responding so bi-directional serial will be used. If that makes sence.<<

Andy with only 1 pin, you can control bunches of PICS. Remember the SERIN command? it will only work if a certain sequence of data is received.

Lets connect up 10 PICS (receiving PICS) on 1 PIC that is the transmitter ok?

SEROUT Pinx,N2400,"Chip1Y"
SEROUT Pinx,N2400,"Chip2Y"
SEROUT Pinx,N2400,"Chip3Y"

See how this works?? if the transmitter sends "Chip2Y", the other recievers will ignore the command...Why? because the SERIN is NOT "Chip2".

Andy>>would be great to have this ability:<<

You have it now... <g>


Andy>>Send the PIC serially "MNx" where x is the port to turn on.
The PIC turns on port x for 1 second then returns to monitoring the serial data.<<

I just showed you how to do it above! If you need some more help, just ask!


Andy >>Send the PIC serially "MNi".
The PIC sees that code then transmits back "I am here",
then returns to monitoring the serial data.<<

You have already been shown!... just ask!

Dwayne