General area when it fits no where else

Moderator: Mmiscool

User avatar
By Ecoli-557
#52588 All DONE!
I can read from the reader all 5 bytes, put them in individual vars, convert decimal to hex AND provide the tag ID!!!
Code below for others who may want to read a tag. This is just a code fragment now, but I will put with other code and thanks to Mike, will offer a RFID lock.

Code: Select allmemclear
'dimension string and numeric arrays
dim h$(5)                        'Hex array
dim d(5)                        'Decimal array

serialbranch [serialin]
wait

[serialin]
'Try this a byte at a time????
do
    d(1) = str(serial.read.int())
    d(2) = str(serial.read.int())
    d(3) = str(serial.read.int())
    d(4) = str(serial.read.int())
    d(5) = str(serial.read.int())
Loop while Serial.available()         'loop through and put each byte in its own var

    for x=1 to 5                  'Converts dec to hex in bytes
        h$(x)=hex(d(x))       
next x

for x=1 to 5                     'This confirms by printing that it is working
        print "x=" & x & "  " & "decimal=" & d(x) & "  " & "Hex=" & (h$(x))
next x   
    print hextoint(h$(1)&h$(2)&h$(3)&h$(4))      'Prints tag ID in decimal - HAS TROUBLE HERE
end



Print Output:
x=1 decimal=0 Hex=0
x=2 decimal=130 Hex=82
x=3 decimal=107 Hex=6b
x=4 decimal=111 Hex=6f
x=5 decimal=134 Hex=86
8547183
Done...

Thanks to Mike an 'Bugs' - you guys pointed me in the right direction and perusing the Arduino pages also helped with what I could do with the 2 new statements.

Will push an example later to the Projects section.

Thanks and Regards,
Steve
User avatar
By bugs
#52590 Glad you got there - misleading datasheet notwithstanding!
(from your first post)

2.CHECKSUM: card 10byte DATA entire do XOR operation
|-02-|-----10 ASCII Data Characters-----|-----Chechsum-----|-03-|

Sorry if I lead you down the wrong path. I see from your final program that the device IS actually sending the raw 5 bytes - not as specified on the datasheet.

Off to the other forum section to add my voice to those nagging Mike to show the version number on the download page.
User avatar
By Ecoli-557
#52591 Thanks Bugs for the assist. Yeah, started with bad info as well. I thought that WAS the data from this device turns out it was not.....
You gave me ideas and I worked them out.
Thanks again,
Steve