Jan 6, 2013 — Making an LED light writer


Back in October, a friend of mine sent me a link to a reddit post where the user austron was showing off an LED light writer he had built. I thought it would be fun to recreate this project using an Arduino.

The first step was to wire up some LEDs on a breadboard and get them connected to the Arduino. I forget exactly why I chose to use 8 LEDs, but it seemed like a good number at the time. As I show later, it turned out to be a good choice. Below is a picture of the breadboard and Arduino. In case it’s not clear what’s going on, take a look at the accompanying schematic.


There’s nothing special about the digital pins I used. If you wish to create this project yourself using the code I provide, you’ll need to use 8 pins that are sequential.

Since the light writer consists of a single column of eight rows, each character that will be displayed needs to be sliced up. Below are two of the many ways in which the letter C can be split up. I chose to go with the one on the left. (Red squares represent lit LEDs, and white squares are unlit LEDs.)


After splitting letters up, they can be easily represented in the Arduino sketch. During the fist iteration of my code, I did everything manually:

It’s a pain to have to write out all that code for a simple message. And what if I wanted to display a different message? I would need to copy and paste and rearrange, and end up with a big mess. Making a function for each character would eliminate some of this mess:

If I had done this for every character, I could display the word “hello” by typing:

h(); e(); l(); l(); o();

Being able to quickly call a single function is convenient, but writing out each column of each letter like I did for the C is not. If you go back and count, you’ll notice that I had to use digitalWrite() 18 times just to represent the letter C. If I had continued to do this with every letter, that would have been a lot of code!

Instead of wasting time typing that all out, I began to think of a compact way in which I could represent an entire column at once. A byte seemed to be perfect. It holds 8 bits, and each bit represents an on-off state. I had 8 LEDs, and each LED is either on or off. Now, Instead of a single line representing a single LED state, it could represent an entire column’s state! The picture below helps visualize how the letter is represented using bytes:


I created the function lightUp which takes one of these bytes and turns on the corresponding LEDs. As I mentioned earlier, it doesn’t matter what digital pins are used, so long as they’re sequential. The loop in in the lightUp function is the reason for this.

After converting entire columns to bytes and creating the lightUp function, the letter C could now be represented by this code:

5 lines instead of 18. Not bad! This could be made even more compact by having the lightUp function work on an array of bytes.

To further reduce the amount of code, I decided to store the message as a string. A loop could then be used to iterate over each character in the string, and that letter’s corresponding function called:

After adjusting the time delays between individual characters and words, I was able to come up with some decent results:


Here’s a link to the full Arduino sketch file: https://gist.github.com/83156afded367c106bb7