For some crazy reason, I wanted to make barcodes. I have no real reason why. I guess I wanted to be able to read barcodes, or make a reader for barcodes. So in order to do that I need to be able to make them.
Of course there are TONS of barcode systems. Some are very tempting, but one of the simplest seems to be
Code 128. This is used fairly often, and it seemed pretty robust.
Barcodes are basically set up with a few bars in the front to tell you which part of 128 you are using (A, B, or C), then individual characters come along. Each character is 6 stripes long starting with black and alternating. Varying the thickness of the stripes will give you each character. So, for example, "A" is 111323, that is, 'a black stripe that is 1 unit wide, a white stripe that is 1 unit wide, a black stripe that is 1 unit wide, a white stripe that is 3 units wide, a black stripe that is 2 units wide, a white stripe that is 3 units wide. Look at the animation below
The end of the bar code is a check number and a stop character that is 7 bars long and unique. Here is the chart that I used from Wikipedia
There are multiple ways to encode a message, so I just used code B throughout. There are Shift keys so that the following character is in the shifted language. Also, you can encode '12' as a '1' followed by a '2' or as a single character '12'. I wonder if I could make something so that given a message it would give me the simplest barcode... hmm...
Anyway, I encoded messages using just column B using
Mathematica.
I first changed a string like "Hello World" to its list of black and white bar notation using
So now I can try "Hello World"
encode uses another function to find the check number
This is not too important, and I won't go into it. Basically, it calculates another character based on all of the characters in your text. This is a standard way of know when you got the right answer when you are reading it. Just do a quick check.
Then I plot it (with a bunch of rectangles)
I only plot black rectangles because that is all I need to plot.
Here are some examples
Note that whatever the message is, it always starts with 211214 and always ends with 2331112.
Next, on to the barcode reader!