Shop OBEX P1 Docs P2 Docs Learn Events
SERIN command help - reading a specific BIT — Parallax Forums

SERIN command help - reading a specific BIT

CalypsoCalypso Posts: 1
edited 2008-04-07 16:40 in BASIC Stamp
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. freaked.gif
Thanks!





Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-07 16:40
    So, you want to receive serial bytes and pick out the contents of bit 1 of each serial byte?

    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").
Sign In or Register to comment.