As you have seen, I’ve been fooling around with segmented LED displays of late. It occurred to me that I could use Excel to simulate any combination of the seven segments. Having the numbers 0 to 9 and letters A to F as in hexadecimal notation is okay, but sometimes you want to have another combination, not readily available in source material.

This is every combination of seven segments you can use:

Seven segments. Source: Wikimedia Commons

But figgering out which of the segments should be used isn’t that simple. For example, if you have a four digit, seven segment LED, and you want to have it display temperatures like 24°C, you want to have the first two showing the actual numbers, the third to show the upper four segments, and the last one the letter C. If you have read the first 2 parts of my LED series, you will know by now that it would be a matter of sending

[0xa4, 0x99, 0x9C, 0xC6]

to the display. But how to figure out the hex code for the upper four segments turned on?

For this I created the Excel sheet. There is a formula that looks at any binary value you want to send to the display, and both shows you the LED as red bars on black background and the corresponding HEX code.

Calculator in action

The way it works is this:

Look at the blue section with the letters a-g on it. These are the segments of the LED. Currently I wanted to see how to form the letter C, so I looked at the letters and want to turn on a, d, e, and f.

In this system, 0 equals ON and 1 equals OFF: Also, the bits are read from the decimal point to segment a. Hence, to have the letter C, your binary is 11000110. Enter this in the green Insert Binary Number field, and note corresponding decimal value. Enter that in the yellow Insert decimal for LED field, and the LED shows what you have.

The way this works is rather simple. Each of the segments is looking at a certain character of the binary value you are wanting to show This is the a segment on top of the digit:

=IF(MID($C$2;8;1)="1";"";"─")

If there is a 1 in it, the segment is off, otherwise it is on. This is done for each of the segments. I know it is overkill to have all the calculators for all conversions between binary, hexadecimal, and decimal, but I just added them because they all work the same way.

Remember to use decimals in the yellow field, otherwise you will get unexpected results. Also, if you see hash marks in the LED simulation fields, just go to the yellow Decimal field, make sure it has a valid value, hitr F2 and then Enter. This will fix it.

The worksheet is locked, to prevent accidental entries or edits to the formulas, but it doesn’t have a password, so if you want to edit it, feel free. As a bonus, there is another worksheet showing you how to connect the 4 segment display to an Arduino.

I hope this is useful for you, as it has been to me many times already.

http://www.sabulo.com/sb/wp-content/uploads/2019/09/binaryshow.zip

Categories: ExcelLED

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.