Message Board Assembly

Post Image
Posted on Updated

Today I will be making an LED message board controlled by a Raspberry Pi 3. I will be making the board, writing the program to control the board, and, lastly, I will write a small web service to fetch a message for the board to display. This section deals with the hardware assembly needed for the board. I will try to be as in depth as possible, but since some people don’t like details, I will provide a quick summary at the start of each section listed in the Contents. If you are looking for the other components to this project, click here for writing the program and click here for writing the web service.


Objective

The end goal of this project is to be able to programmatically control an LED light strip from a Raspberry Pi 3. To do this, we will need to setup a circuit that enables us to control the LEDs. With this in mind, I would like to warn you that you should do this at your own risk. It is very possible to short circuit something, or, worse, hurt yourself, so it is important you proceed with caution. Once we have a valid circuit setup, we will proceed to the programming portion of this project.

Note

You could just as easily do this with an Arduino, but I have chosen the Raspberry Pi for two main reasons:

  1. I want to be able to run multiple programs at the same time, so I can run the LED board simoultaneously with another project.
  2. I want to be able to change the message by reading from a web service. This is done very simply with the Pi.

If you do not care for writing/reading from a web service, don’t care for multitasking, or don’t have a Raspberry Pi, go ahead with the Arduino. If you are to go this route, however, I suggest looking online for a different tutorial because the circuit I’m wiring is designed for the Raspberry Pi GPIO hardware, and the software I am going to write is somewhat specific to the Raspberry Pi.

Materials

Here’s a list of materials I used when designing this circuit. You’re list may be a little different as noted below:

  • 5V Power Supply This will be used to power the LED strip, and outputs at 5Volts/12Amps taking a standard household outlet input of 110V AC. It’s a fairly common power supply, so I bought one off of Amazon for around $20.
  • LED Light Strip The mother of all parts! There are a lot of different types of LED strips you can choose from. I chose a WS2812 strip, which I also purchased from Amazon. If you are following along, you can choose any type that is supported by the software we will use — check out the list in the Drivers section of the BiblioPixel framework. BiblioPixel is a cross-platform API that is used to control LED strips. When using the WS2812 or WS2811 LEDs, however, you will also need to install other software. I will leave that for the next section of the project, and move along for now. Some of the supported LED strips include LDP8806, WS2801, and APA102. Don’t worry if you don’t know what the names stand for, they just indicate the protocol the hardware needs to follow to properly control the LED strip. BiblioPixel handles all this for us, so we just need to choose a supported protocol.

    Note: Though you will be able to use any protocol supported by the BiblioPixel library, different protocols have different signal inputs and, therefore, different circuit specifications. This will result in a slightly different circuit than the one I designed for the WS2812, as noted in The GPIO and LED Strip Setup section of Assembly and Setup. Check out the Resources section for a list of materials relavent to the LED strip you have.

  • SN74HCT125 Integrated Circuit This is just a voltage level translator, used to increase the voltage of the GPIO signal coming from the Raspberry Pi. The input signal of the LED strip is expecting about 5V, but the Raspberry Pi outputs at 3.3V. We need this device to bump up the remaining 1.7V. You can buy these in various places, I chose to buy mine at DigiKey with a lot of other parts to make the shipping worth it.
  • Miscellaneous – In addition to the materials stated above, I also used the following to support the assembly of the components and troubleshooting: Standard Electrical Wire, Solder and Soldering Iron, Breadboard, Wire Cutters, Electrical Tape, MultiMeter, Hot Glue Gun, and Cardboard.

Assembly and Setup

In order to get these LEDs to light up, we need to create a circuit that correctly powers the LED strip and correctly sends information to the strip. If you feel like you can handle this, you can skip ahead to the finished product; otherwise, just follow along in order from start to finish.

Setting up the power

First things first, let’s just get the power setup. My power supply did not come with a power cord, so I simply cut one off of an old VCR. All we need is something that safely goes into a household wall outlet (only 2 prongs necessary). Strip down the outer cable exposing about 1 inch of the black and white wires. For the USA, the black signals live (L), and the white signals neutral (N), and tightening the screws. Now strip down the white and black wires about a half an inch exposing the metal wiring.

To connect this to the power supply, we need to screw the exposed black and white wires down. Making sure the plug is NOT connected to the wall, let’s connect the black wire first. My supply signals L for live input: this is where the black wire needs to go. Loosen the screw for this input until you are able to fit the wire inbetween the gap the head of the screw creates from the base. Make sure to insert the wire to the left of the screw, as we will tighten the screw clockwise, further securing the connection. When this is complete, do the same thing for the white wire connecting it to N (neutral). Now test out the supply by plugging in the end of the cable to the wall outlet. If all went well, the LED indicator on your power supply just turned on! To feel more confident it’s working, you can hook up a multimeter to the +5V/-5V inputs and make sure you’re getting the correct voltage.

Now, unplug the cable from the wall so we can move onto connecting output wires. In order to connect the +5V/-5V outputs, we need to solder jumper wires to the 18 gauge wire we will use to connect to the power supply. Pick out a red wire to signify positive and a black wire to signify negative. The length you need depends on how far you are keeping the breadboard from the power supply. With these two ready, go ahead and solder a red jumper wire to the red wire and a black jumber wire to the black wire. I added electrical tape to the connection point, for now, to make sure there aren’t any accidental shorts. It is VERY important not to contact the red and black wires when the power supply is plugged in. This is where you can either hurt yourself, or ruin the power supply, so proceed with caution. When all is done, you should have something that is able to connect to the breadboard! Again you can test the connection by using a multimeter.


The GPIO and LED Strip Setup

Now that the power supply is setup, let’s get an understanding of the Raspberry Pi 3 GPIO hardware and how it relates to sending information to the LED strip. In a nutshell, we’ll be sending a varying amount of voltage via PWM to the LED strip from one of the Pi’s GPIO pins. This will be a special pin (GPIO 18) that is able to send a PWM signal. Depending on the type of LED strip you are using, the exact circuit setup will differ slightly to achieve the above goal. Take a look at the diagram of the Pi’s GPIO:

In earlier versions of the Pi (Model A), there were 26 pins. With the latest version (Model B), there are now 40, keeping the same functionality of the first 26 pins. There are many different functions of these pins that include DC Power, PWM Signals, SPI signals, Ground, and basic high/low signals. There are two different ways to identify the pins: either the BOARD Standard, or the BCM Standard. The BOARD Standard identifies the pin based on actual pin number, as identified in the picture above (#1-#40). The BCM Standard preludes some of the pins with GPIO, identifying the pins that can actually be used for sending data out. For this project, I will be speaking in terms of the BCM Standard when identifiying pins, unless otherwise stated.

Let’s skip ahead a little bit and talk about the LED strip. As I said earlier, I am using a WS2812 strip, which comes with 3 different inputs: Ground, Data In, and +5V. If you chose to use a different model, you will have different inputs. Some protocols have 4 inputs: Ground, Serial in, Clock in, and +5V, or Ground, Data In, Clock Out, and +5V. The exact setup of the circuit will depend on you’re model, but the programming side of things will be very similar. I will provide links in the Resources for suggested circuits for different models.

Finishing up the Circuit

Note: To design the following circuit make sure you have jumper wires connected to all inputs of the LED strip as well.

Now that we have an understanding of all the components, let’s put this thing together. Start off by connecting the red +5V jumper wire from the power supply to any + input along the side of the breadboard, and connecting the -5V jumper wire from the power supply to any – input along the same side of the breadboard. This will cause any jumper wire connected to the same +/- vertical line to seemingly be connected to the +5V/-5V from the power supply. Now, connect the +5V input from the LED strip to the same + input line the +5V jumper wire is connected to, and connect the Ground input from the LED strip to the same – input line the -5V jumper wire is connected to. There might be some residual voltage from the -5V signal that is clogging up the – input. To make this Ground, connect any ground pin from the Pi to the – input line of the breadboard. Boom, the negative line is now ground. You should have someting that looks like the following:

Now let’s connect the SN74HCT125 IC to the center of the breadboard, bridging the horizontal input lines on each side of the breadboard. If you look at the data sheet for the IC, you’ll notice that it needs an input voltage to power the circuit at pin 14 of the IC, and a Ground signal coming from the 7th pin of the IC. In this case, our input voltage will be our +5V from the power supply, so go ahead and connect a jumper wire from the + input line of the breadboard to any input horizontal to pin 14 of the IC. Also connect the Ground pin (pin 7) of the IC to any pin in the – input line of the breadboard. This setup allows our IC to function properly.

Now, let’s talk about the IC for a little bit. There are 4 buffer gates, which just means there are 4 different signals you can bump up to 5V from the originating voltage (in our case 3.3V). Each one of these requires 3 different pins from the IC, one is a high/low switch voltage, one is the input data, and the last one is the output data. In the perspective of the IC (according to the datasheet), pins 1, 2, and 3 form a single buffer gate, 1 being the high/low switch, 2 being the input data, and 3 being the output data. Here’s a bit more detail into how we’re using all these pins:

  • When the volatage for Pin 1 is high (on), it opens the IC switch and there is no voltage flowing to the output. When Pin 1 is low (off), it closes the IC switch and there is voltage going to the output. Since we always want data flowing into our LED strip we will connect this pin to Ground, creating a low signal.
  • Pin 2 is the input data we want to increased in voltage. As stated previously, we will be using GPIO 18 as the input signal for the LED strip, so connect Pin 2 to GPIO pin 18
  • Pin 3 is the output data, or the result of increasing the voltage from pin 2. This should be connected to the data in input of the LED strip.

When you are finished you should have a circuit that looks like the one below (minus the bright LEDs 😉):


Building the Board

The final step to getting this board ready is actually making the board. You’ll want to first decide how many rows and how many columns you want. My strip had 240 LEDs, so I decided to make the board 5 LEDs high x 48 LEDs wide. I designed the letters to be 4 LEDs wide (3 for the letter and 1 for an empty space to increase readability), so that makes about 12 letters visible at a time — should be able to fit “Hello World!” quite fine. Whatever you decide on is up to you, but make sure to pick dimensions that allow you to insert a proper number of letters to discern words.

If you look closely at the board, you’ll see the LEDs connect to one another by 3 metal pads (Ground, Data In, and +5V). If you look even closer you’ll notice that metal pads have a thin line running through the center of them. This line indicates where to cut the LED strip if you plan on segmenting it — just like we are going to do! Go ahead and make sure the circuit is disconnected, and make cuts at the appropriate positions in the strip to form your dimensions. Since mine is 5×48, I need to make cuts at every 48th LED.

After you’ve made the appropriate cuts, space the LEDs out on cardboard forming the skeleton of the message board. Make sure each strip doesn’t touch each other as the letters will become very short, and it will be hard to recognize words. Once you have them in a position you like, you need to make sure you oriented each segment correclty. The data out at the end of the first strip should be going into a data in that is the closest it can be. That will be the data in at the end of the second strip. From there the data out for the second strip will be at the start of the first LED in the segment and lead to the data in at the start of the third strip. As you can see this snake pattern will continue until the end of the strip. I unfortunately hooked up the board backwards and had to run long wires behind the cardboard to connect the strip properly.

Now that everything is oriented correclty, hot glue everything in place. Once that dries, you’ll want to cut the cardboard in the shape of a rectangle leaving about a 1 inch cushion from the board. Now you can start soldering wires. As stated in the previous paragraph, make sure to wire the data out of one strip leading to the data in of the next strip. If you are using a different model LED strip, make sure to follow the same pattern, but modified to fit your model. After wiring this portion, you’re now ready to test the circuit!

Testing

So we have a circuit… how do we test it? Well, we actually need to install software to test this out. I will explain this in detail in the next section, but if you really want to see how this thing looks, I’ll explain a little bit now. Go ahead and install Jeremy Garff’s rpi_ws281x library on your Raspberry Pi. BiblioPixel actually requires you to install this when controlling the WS2812 LED strip. Since the Pi is an OS and not a realtime system, and the WS2812 protocol is a real time protocol, it would seem we would have an issue getting the LEDs to work properly. This is where the rpi_ws281x library comes in, and why it is necessary to install in order for BiblioPixel to work. The rpi_ws281x library sends realtime data to the LED strip through Direct Memory Access (DMA), sliding right by the OS! Once you’ve installed rpi_ws281x, go to the install directory, and open up rpi_ws281x/python/examples/strandtest.py in you’re favorite text editor. Make sure all the definitions at the top of the file suit the circuit we just made (GPIO pin 18 in use). Finally, when it looks good save and quit, and type the following in the command line:

sudo python3 ./rpi281x/python/examples/strandtest.py

Enter your password, and you should start seeing the LEDs light up on the screen! It should resemble the photograph at the top of the page. This runs through a bunch of different animations controlled by the rpi_ws281x library. We could actually just use this library to write our message board from scratch, but then the readers with different model LED strips would be left out! BiblioPixel allows us to maintain consistency across all LED strip models. It’s also great for use cross-platform.

Conclusion

Let there be light! Now that you’ve designed the circuit and tested it out, we’re ready to write some code. The code is written in Python, and will allow us to do pretty much anything you are able to do with a bunch of LEDs in a rectangular shape. Before moving onto the programming section, make sure to the circuit is functional. You can’t write any messages without a working circuit!

Troubleshooting

Here are a bunch of troubleshooting tips if you can’t get this thing working:

  • If you’re lights work, but they are not animating properly:
    • Double check the circuit is setup properly. I remember I forgot to connect the Pi to ground and I experienced a similar issue.
    • If some of the lights are working, but not all, this could have something to do with the data in line. Check to make sure the last LED that works is sending voltage from the Data In to the next LED. If the line is damaged, there may not be data traveling to the next LED.
    • Check to make sure the voltages at each part of the circuit are where they need to be.
    • Make sure the wire connections are secure and the soldering points for the data intact.
    • I would guess 9/10 times this is caused by damage to the Data In line. Since this is the line that actually controls the colors of the LEDs and which ones are lit, it makes sense that something is going on with this line.
  • If you’re lights do not work:
    • Make sure the voltage coming from the power supply is indeed +5V/-5V by using a multimeter.
    • If the power supply is fine, make sure the IC is oriented correctly and the dimple is facing the right way. It could be you oriented it backwards and so you’re connections to the IC don’t work.
    • Verify the Data In voltage coming from the output of the IC is going into the LED strip, and the strip is getting the correct voltage.

Resources

Here are some helpful resources for the different types of LEDs:

Comment Below

Your email address will not be published.

*This field is required.
*This field is required.
*This field is required.