SERIN command help - reading a specific BIT
Calypso
Posts: 1
Hi all,
I'm fairly new to using a STAMP (to control things other than simple relays).· So, this has me a bit stumped.
I need to read specific data from a serial stream.· In other words, how would the SERIN command be set to read the value of BIT1?·
I tried doing something like,
Rad_dat var BYTE
Rad_bit·var BIT
Rad_bit= Rad_dat.BIT1
And, then DEBUG it to see the value.· (Once I see the value, I'm pretty sure I can take it from there.)
I'm just not geting it.
Thanks!
I'm fairly new to using a STAMP (to control things other than simple relays).· So, this has me a bit stumped.
I need to read specific data from a serial stream.· In other words, how would the SERIN command be set to read the value of BIT1?·
I tried doing something like,
Rad_dat var BYTE
Rad_bit·var BIT
Rad_bit= Rad_dat.BIT1
And, then DEBUG it to see the value.· (Once I see the value, I'm pretty sure I can take it from there.)
I'm just not geting it.
Thanks!
Comments
By the way, if you add DEBUG statements, you will miss some of the incoming serial bytes
because the Stamp will be busy for a time sending the debug information to the PC and it
can't do two things at once.
1) You need to receive from the serial stream one byte at a time with: SERIN <pin>,<Baudmode>,[noparse][[/noparse]Rad_dat]
Read the chapter in the Basic Stamp Manual on the SERIN statement for details and examples.
2) You need to refer to bit 1 of the data byte. You can just use "Rad_dat.BIT1" as you've shown or you can
copy the value to another variable as you've also shown ("Rad_bit = Rad_dat.BIT1").