# Create square wave patterns from binary strings This script turns a binary string into a square-wave pattern. It is intended for creating embroidery patterns based on programs for my paper computer. The output is formatted as if the data is being sent over an 8-bit data bus — see the [reference image below](#format-reference-image). ## Use ``` ./square-wave-from-binary.js bin.txt ``` The input must be a text file containing nothing but 0s and 1s (no spaces, newlines, etc). It must be an even number of 8-bit bytes in length. ## Example output ``` 01234567 01234567 01234567 01234567 ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▀▄▄▄▄▄▄ ▀▄▀▄▄▄▄▄ ▄▀▀▄▀▄▀▄ ▀▄▀▄▄▄▄▄ ▄▀▀▄▀▄▀▄ ▄▄▄▄▄▄▄▄ ▀▀▄▄▄▄▄▄ ▀▄▀▄▀▄▄▄ ▀▀▀▄▀▄▀▄ ▄▄▄▄▄▄▄▄ ▀▄▀▀▀▀▀▀ ▀▀▀▀▀▀▀▄ ▀▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ 01234567 01234567 01234567 01234567 ``` ## Format reference image ![](https://www.nutsvolts.com/uploads/wygwam/NV_1007_Martin_Figure09.jpg) (From [Nuts and Volts](https://www.nutsvolts.com/uploads/wygwam/NV_1007_Martin_Figure09.jpg).)