Converting Hex String to Binary array

Hiya, I was wondering if anyone could give me some advice with a little conversion problem.

Im currently working on a project based around the RFID Spoofer project (http://www.instructables.com/id/Stupid-Simple-Arduino-LF-RFID-Tag-Spoofer/), and I cant work out how to convert a simple char array e.g. 25005F0C88 to its 4 bit binary equivalent. I also need to add some 1's nd 0's in as pairity bits and start and stop bits etc..

Here is how it is done in the original project:

//this is the card data we're spoofing. It's basically 10 hex F's int data_to_spoof[64] = {1,1,1,1,1,1,1,1,1, 1,1,1,1,0 ,1,1,1,1,0, 1,1,1,1,0 ,1,1,1,1,0, 1,1,1,1,0 ,1,1,1,1,0, 1,1,1,1,0 ,1,1,1,1,0, 1,1,1,1,0 ,1,1,1,1,0, 0,0,0,0,0};

(start bits)
111111111

(10 rows of data - the card serial number)
(the first 4 bits are the data, the last is the even parity bit)

11110
10100
10001
11000
10010
11101
11110
00000
00011
01010

(then it sends the column parity bits, even parity of the rows above)

1101

(last a 0 stop bit)

0

But how do I take my Array and convert it to that?

Thank you!

You need to do this one step at a time.

You have a character ('2' or 'A' or 'F').

You need to convert that to a byte. If the character is >= '0' and <= '9', the byte value is (c - '0') where c is the character. If the character is >= 'A' and <= 'F', the byte value will be (c - 'A' + 10).

The byte value will then always be in the range 0 to 15. You can determine which bits are set using bitRead.

Convert each character in the array using a for loop.

Do whatever you need to with the resulting bit information.

Thanks! much appreciated!

Everything works fine now :smiley: