help with hex while mapping 14 segmant display

I have this Adafruit 14 segment alphanumeric display. To turn on the invidual segements you send a hex number like the following:

alpha4.writeDigitalRaw(0, 0x0001)

The above would turn on the "A" segmant as show here:

I would like to determine the hex value to turn on each segment individually. Can someone explain to how to identify the correct hex value for the mapping in the image above?

Thanks! Jake

You just write out the bits you want to turn on as a 1 and the bits you don't as a zero. Something like shown here:- http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

Thank you Mike. I read the tutorial you linked to but am still unclear.

In the image I posted above, the segment for the decimal point is labelled "DP" and counting from right to left is #14.

So how would I represent that with the 0x____ notation for the code? 0x000E maybe? hex E is 14.

alpha4.writeDigitalRaw(0, 0x000E)

Thanks.

The raw image map you have in the attachment. Under it, write: 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Binary = 8 4 2 1 for each group of 4 sagments Hex = the sum of what one you need. With 10 11 12 13 14 15 replaced with A B C D E F Example for F = 00100000 or 0010 0000 or 20 = 0x0020

Thank you Steinie! This is making sense.

Using your method I came up with the following for the "DP" decimal point segment in the attached image above:

0010 0000 0000 0000

I ran that through a decimal to hex converter and came up with 0x2000

I'll give that a try when I get home.

Thanks again, Jake

Correct.

I ran that through a decimal to hex converter and came up with 0x2000

Well no. It is a binary input, decimal has nothing to do with it. As you only convert four bits at a time you should be able to do it in your head. That is why hex is used, it is so close to the bit pattern.

Write down the 16 bit patterns and associated single hex digit and use it as a look up to convert it. Soon you will throw the paper away and you will just be able to do it straight off. It is much easer than Learning your eight times tables.

Thanks Mike. I’ll give it a try.

I’m at home now and the 0x2000 didn’t turn on the decimal point.

I got it!

The first 4 binary are hex 4, the rest zeroes, so 0x4000 worked.

Thanks for the help. Makes sense now and I can do it in my head :)

Cheers, Jake

Update:

For anyone who may come along later and read this, there is a typo in the Adafruit documentation (attached image). See below for the correction.

The segments in the above image are labeled with letters. The first four bits from left-to-right below the "this mapping" line are incorrect. The image shows them as:

0 0 DP M

The correct letters are:

0 DP M N

Thus to turn on the decimal point you send 0x4000.

Jake

I ran that through a decimal to hex converter and came up with 0x2000

Glad you got it to work. So the documentation was wrong, but the calculation was correct.

Yes Steinie, thanks for your help!

Jake