SERIN command
Tore
Posts: 2
Hi. I try again.
Are there anyone who can give me some feedback on this project. (Schematic or code)
I just want to read som data into the BS2. And if this data is correct i HIGH 10 to read out the result. OK or NOT OK.
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
T9600·····CON···· 84
buf········ VAR···· Byte(10)
char······· VAR···· Byte
RX········· PIN··· · 0························· 'Pin 0 if i use SIN pin on BS2 or 14 if i use I/O pin 14.
LOW 10
main:
SERIN RX, T9600, [noparse][[/noparse]WAIT("A"), STR buf\10]······ 'Put the recieved number "0002746012" into "BUF"
IF buf = "0002746012" THEN
· HIGH 10
ELSE
· LOW 10
END IF
GOTO main
Will this code be any good and is it best to use SIN or a I/O pin if you look at the attached shema ?
Is it possible to do this as simple as this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tore Grønås
Are there anyone who can give me some feedback on this project. (Schematic or code)
I just want to read som data into the BS2. And if this data is correct i HIGH 10 to read out the result. OK or NOT OK.
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
T9600·····CON···· 84
buf········ VAR···· Byte(10)
char······· VAR···· Byte
RX········· PIN··· · 0························· 'Pin 0 if i use SIN pin on BS2 or 14 if i use I/O pin 14.
LOW 10
main:
SERIN RX, T9600, [noparse][[/noparse]WAIT("A"), STR buf\10]······ 'Put the recieved number "0002746012" into "BUF"
IF buf = "0002746012" THEN
· HIGH 10
ELSE
· LOW 10
END IF
GOTO main
Will this code be any good and is it best to use SIN or a I/O pin if you look at the attached shema ?
Is it possible to do this as simple as this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tore Grønås
Comments
Reading the numeric string into the buffer would work, but there is no string comparison. You can use the DATA statement to store one (or more) strings in the EEPROM where the program is stored, then use a loop to read characters one at a time (using the READ statement) and comparing them one at a time with the received string.
I will go down to 9 volt on supply voltage and it seams like i can use the code for RFID.bs2. Then i will try this on work monday.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tore Gr