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.
memclear
'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
- Albert Einstein