The SerReceive command reads a byte variable from the Serial Port
so the line SerReceive 1, Temp wont work as temp is defined to be a string.
SerReceive will only read a single incoming byte .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a few things to know
String is a special array where you store the length in the first element temp
to fill the array/string, I think you have to receive and put in each element
DIM temp as string
……….
SerReceive 1, Temp(1)
SerReceive 1, Temp[(2)
SerReceive 1, Temp(3)
SerReceive 1, Temp(4)
Temp(0) = 4
I don't see a string compare in "lowlevel" string routines
So one at a time to check for valid "keycode"
IF Temp(1) != "1" then goto main
IF Temp(2) != "2" then goto main
IF Temp(3) != "3" then goto main
IF Temp(4) != "4" then goto main
opendoor
This is just to give some ideas how to do it.
GL
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have this:
#chip 12F683, 8 'mhz
#config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off, bod=0ff
dir GPIO.1 out ;open
dir gpio.0 in ;rx
#define RecAHigh GPIO.0 off
#define RecALow GPIO.0 on
InitSer 1,r1200,1,8,1,none,invert
dim temp as string
main:
SerReceive 1, Temp
if temp = "1234" then opendoor
goto main
sub opendoor
set gpio.1 on
wait 2 s
set gpio.1 off
wait 10 s
end sub
but i get a error on compile that says "cannot store ser_byte in the string varible temp"
Why?
The SerReceive command reads a byte variable from the Serial Port
so the line SerReceive 1, Temp wont work as temp is defined to be a string.
SerReceive will only read a single incoming byte .
so how can i get it to store a string of 4 bytes?
a few things to know
String is a special array where you store the length in the first element temp
to fill the array/string, I think you have to receive and put in each element
DIM temp as string
……….
SerReceive 1, Temp(1)
SerReceive 1, Temp[(2)
SerReceive 1, Temp(3)
SerReceive 1, Temp(4)
Temp(0) = 4
I don't see a string compare in "lowlevel" string routines
So one at a time to check for valid "keycode"
IF Temp(1) != "1" then goto main
IF Temp(2) != "2" then goto main
IF Temp(3) != "3" then goto main
IF Temp(4) != "4" then goto main
opendoor
This is just to give some ideas how to do it.
GL
Mike
just wondering why the reply didn't show up
wierd