Shop OBEX P1 Docs P2 Docs Learn Events
Help with code...RFID and BS2 — Parallax Forums

Help with code...RFID and BS2

Jeff_5_Jeff_5_ Posts: 36
edited 2010-08-05 16:13 in BASIC Stamp
Ok I am new to PBasic and working on writing a program using the parallax rfid reader. MY questions is how can i move on VAR to another. I want to write a function the reads up to five tags at once and stores them in a table.

This is What i have:

Enable PIN 0
RX PIN 1

buf VAR Byte(10)
idx VAR Byte
char VAR Byte

I read in my Tag here

SERIN RX, T2400, [noparse][[/noparse]WAIT($0A), STR buf\10]

Then

For idx=0 to 9
Read idx,char
Debug char

That will print one tag but instead in printing that on tag i want to store in in to a Variable called TAG1 then read a Tag again and Store it in to TAG2 and so on reading up to 5 tags.
Its almost like reading the tags and saving them to a table so then i can compare with them.

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2010-08-05 05:15
    I use the last four digits of the tag and put them into a word sized variable.
    bufVARWORD
    
    ReadTags:
    
    LOWEnable'activatethereader
    SERINRX,T2400,150,Notag_,[WAIT($0A),SKIP6,HEX4buf]'waitforhdr+ID
    HIGHEnable
    


    'SKIP 6' skips the first 6 characters of the tag ID. 'HEX4 buf' converts the last four characters into one numerical value and stores it in buf.

    Rich H

    The Simple Servo Tester, a kit from Gadget Gangster.
  • Jeff_5_Jeff_5_ Posts: 36
    edited 2010-08-05 12:45
    Ok but my question is how can i move whats in the buffer to another variable.
    if i had

    buf VAR word
    Tag1 VAR word
    Tag2 VAR work

    LOW Enable ' activate the reader
    SERIN RX, T2400, 150, Notag_, [noparse][[/noparse]WAIT($0A),SKIP 6, HEX4 buf] ' wait for hdr + ID
    HIGH Enable

    how can i now move whats in buf to Tag1. Then read again and move buf to Tag2 and so on.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-05 13:05
    You're talking about an assignment statement ...

    Tag1 = buf
  • Jeff_5_Jeff_5_ Posts: 36
    edited 2010-08-05 16:13
    Ok I am getting somewhere now. Thats what i needed to know.
    How can i make this work in a loop to where i can read up to 5 tags and store them in the Varabiles Tag1 Tag2 Tag3 Tag4 and Tag5. I think there is a way to do it with a loop but im not sure. I know i will have to compare them all together to make sure i dont store the same tag in two spots.
Sign In or Register to comment.