HackerBoxes 0005: LED Pixels, 2D Matrix, 4x4x4 Cube, and Bluetooth
by HackerBoxes in Circuits > Electronics
11068 Views, 33 Favorites, 0 Comments
HackerBoxes 0005: LED Pixels, 2D Matrix, 4x4x4 Cube, and Bluetooth
Get the LED out! This month, subscribers to HackerBoxes are working with LEDs served three different ways. The first is addressable LED madness using WS2812-based RGB pixels. The second way is in a two-dimensional matrix based on the MAX7219 serial interface chip. Finally, we have a 3-D cube of 64 dual-color LEDs. Along the way, we'll also take a look at a new Arduino UNO compatible offering for 2016, Bluetooth interfacing, and we'll all stay super cooled with a tasty beverage served in an exclusive HACKERBOXES themed koozie.
This Instructable contains information for working with HackerBoxes #0005. HackerBoxes is the monthly subscription box service for electronics hobbyists, makers, and hackers. Even if you are not a HackerBoxes subscriber, you can always join in the fun using your own materials and equipment. Of course, if you would like to receive a box like this right to your mailbox each month, please SUBSCRIBE HERE and join the HackerBoxes movement. We would love to have you!
HackerBox #0005 Introduction Video and Box Contents
- HackerBox #0005 Component Reference Card
- RobotDynUNO - Arduino UNO Compatible
- WS2812B RGB LED Pixels
- Alarm Wire - 22gauge - Four Conductor
- QUAD FC-16 LED matrix (8x32 LEDs)
- Animated 4x4x4 LED Cube Kit (64 LEDs)
- HC-05 Bluetooth module
- Male-Female Dupont Hookup wires
- Exclusive "got root?" HackerBoxes Koozie
RobotDyn UNO CH340G/ATmega328P
This microcontroller board is a new design for 2016. It features an SMD-version of the ATmega328P, a CH340G serial-to-USB interface chip, and of course the Arduino bootloader for use with the Arduino IDE.
A big difference between other similar UNO boards, aside from being black, is that this one connects to the computer via a microUSB cable. This is the same cable that is used for almost all Android phones and tablets, you they are very readily available and inexpensive.
Note that the new CH340/CH341 serial-to-USB interface chip may require a software driver. If you have not interfaced with one of the chips before, you will probably need to install the driver on your computer to allow the Arduino IDE to communicate to these boards. There are drivers for the CH340/CH341 serial-to-USB interface chip available for OS X, Windows, and Linux. Here is a video on the topic.
If you haven't used an Arduino before, you can find a lot of tutorials online. To get started, install the IDE on your computer (just search the web for Arduino IDE and your OS type). Hook the UNO up to your computer using a microUSB cable, and then load the "blink" sketch from under the examples menu. You don't even need to hook up an LED (although you can if you like) since there is one on the board already. Once the blink program works, you can change the values of the delay() calls from 1000 to 100 and see that the LED blinks much faster. You have just hacked your first code. It's just that easy. If you'd like a little more step-by-step detail on this process, here is a very nice reference: blink.
RGB LED Pixel Mini PCBs - WS2812B
The WS2812B (datasheet) is an individually-addressable red-green-blue (RGB) LED with an integrated controller and driver. Adafruit manufactures a whole universe of really cool WS2812-based products branded as NeoPixels. If you enjoy working with addressable NeoPixles, Adafruit is the place to go to find every imaginable variant and configuration.
As shown in the circuit diagram here, these pixels can be easily chained together such that they only require a single I/O pin to control a large number of LEDs. Solid conductor alarm wire provides a nice way to make the interconnections from the microcontroller and then between the pixels.
The Adafruit NeoPixel Überguide provides a wealth of information including links to the Arduino library and example code for working with addressable RGB pixels.
FC-16 LED Matrix - Scrolling Text
An FC-16 module is a small PCB (about 33x33mm) supporting an 8x8 LED matrix wired to a serial interface MAX7219 LED driver chip (datasheet). The FC-16 module has pin pads on each side so that multiple modules can be easily wired in a chain. The photo shows a block of four FC-16 modules that were manufactured as a single unit
The Parola project provides a library and example code for scrolling a text display using MAX7219 or MAX7221 LED matrix controllers and an Arduino microcontroller board. The display may be made up of any number of identical modules that are plugged together to create a wider/longer display.
Click "downloads" on the Parola site to get the library. Unzip the library into your Arduino Libraries folder.
The Parola library uses the MD_MAX72XX library which can be found here and unzipped into your Arduino Libraries folder.
Next, we need to edit the file named "MD_MAX72xx.h" in the src folder. The line reading:
#define USE_FC16_HW 0
must be changed to read:
#define USE_FC16_HW 1
Now we are ready to use the Parola example sketches. The simplest one to start with is HelloWorld. Note the following lines:
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
There are four FC-16 modules (MAX_DEVICES) and pins 10, 11, and 13 (along with 5V and GND) are the ones to wire up from the FC-16 pins to the Arduino using some Male-to-Female Dupont wires.
There are some additional low-level details in this Tutorial on using the Arduino and the MAX7219 LED Display Driver IC.
HC-05 Bluetooth Module
As a preliminary step to using the Bluetooth Module (HC-05) with an Arduino board, get a sketch running on the Arduino that is controlled using serial communications. For instance, the Parola_Scrolling sketch in the Parola Examples folder. Do not wire up the HC-05 Bluetooth module yet. From the start, set the data rate to 9600bps. That is the default for the HC-05 so this just makes it easier to transition later.
Get the program running on the Arduino and working with the serial monitor on your computer (make sure to set the computer serial rate to 9600 as well or it will not work). Now you can disconnect the computer (or just turn the IDE and serial monitor off if you still need it for power) and wire up the HC-05. Now Bluetooth is taking the place of the serial monitor. Sync your mobile device's Bluetooth radio to the HC-05 and run an app like BlueTerm on the mobile device. This will let you type to the serial port from the mobile device just as you did from the Arduino software, but this time, you are wireless.
As an advanced option, if you want to be able to leave pins 0 and 1 connected to the PC (via the USB chip), you can modify whatever sketch you are working with to use the SoftwareSerial and wire the HC-05 rx and tx lines onto two other pins.
You may also wish to try out MIT App Inventor to create a mobile application. If so, there is a detailed Bluetooth tutorial for App Inventor.
As further background, Wikipedia can lead to a lot more details on Bluetooth wireless communications.
4x4x4 LED Cube: Kit Components
- Printed Circuit Board
- 40pin Plastic DIP Microcontroller STC12C5A60S2 (datasheet)
- 40pin DIP Socket
- 64 Super-bright, long-lead, RED/BLUE LEDs
- 4 Color-cycling LEDs (for bottom)
- 5 LED spacers (for bottom LEDs)
- 470UF Electrolytic Capacitor (25V)
- 4 Resistors (nominal 1K)
- 11.0592MHz crystal oscillator
- 3 Ceramic capacitors 22pF (for clock oscillator)
- 2 SIP sockets (40pin breakaway)
- 4 Threaded standoffs (with screws)
- Solid Hookup Wire
- Barrel Power Adapter
- USB Power cable
4x4x4 LED Cube: PCB Assembly
Start by breaking the 40pin SIP sockets into 18 sets of three pins. The six sets along the edge of the PCB with the power socket use all three pins. However, the other six sets do not have a center whole. You can either cut off the center pin with some tiny cutters, or you can use two single pins. The photo shows the first option.
Next, flip the board and solder on the power connector, the electrolytic capacitor (note the polarity), the four resistors (not polarized), and the four round LEDs.
Place the LED spacers onto the round LEDs before inserting them. Putting the flat part of the space closest to the LED seems to provide the most stability. Note that the longer lead of the LED goes into the + hole.
At this point, you can plug in the power and make sure that the four round LEDs light up and color cycle. This serves as a sanity check that you do not have any shorts and that your LEDs and power connections are good.
Finally, solder the other PCB components where the appear on the PCB silkscreen. Note that the 40pin socket has a "half circle" polarity indicator that matches up with the PCB and also with the chip itself.
Screw the four brass standoffs onto the PCB and flip it over. The PCB is now complete. Once the LEDs are properly assembled they are simply plugged into the 18 sets of SIP sockets.
4x4x4 LED Cube: LED Preparation
The 64 rectangular LEDs for the 3D cube are actually dual LEDs. Each one has a red LED and a blue LED allowing each plastic rectangular lens to be illuminated in various shades or red, blue, and violet. The middle lead of the dual LED is the common lead. The shortest lead is for the blue LED. You will note that the sockets on the PCB show a B (blue) side and an R (red) side. The shorter outside pins need to end up connected to the B side and the longer outside pins need to end up connected to the R side.
The 64 rectangular LEDs are arranged in 16 columns of 4 LEDs, so we will work in sets of four. First we lay the four LEDs down with the shortest (blue) pin on the right and the plastic lens pointed away. In this orientation, bend the middle pin up as shown. This keeps all the LEDs facing the same direction to maintain the red/blue polarity.
Form a stack of four LEDs by straddling the outer pins of one LED around the plastic lens of another LED, adjusting the separation so that it is 2cm (8/10th of an inch). This distance is the separation of the LED sockets on the PCB, so it looks nice and symmetric to use it for the vertical separation as well. It is helpful to make a set of 2cm spaced markings on a piece of cardstock (e.g. a business card) to aid with alignment. Once two LEDs are straddled and spaced, they can be tack soldered together. Then add another one on top and repeat until you have a column of four as shown.
Now "just" make 16 of these columns. Yes, this is a little tedious. Break it up into two or four sessions and play loud or meditative music while you are working. This is great soldering practice and training in manual dexterity. Hemostats or alligator clips may be used to hold the LEDs in alignment while soldering.
4x4x4 LED Cube: LED Assembly
This is the fun part. Put in the first two columns of four LEDs so that the bent up middle conductors reach from one column to the one in front of it. Note that the sockets along the edge with the power connector actually have three terminals. For these, bend the middle conductor back down into the middle hole at the bottom of the column.
As you insert each column of LEDs, get everything planned to go so that the polarity can not get messed up and then trim the bottom LED leads to make them all as long as the short lead (the blue lead). This allows the leads to sit fully and firmly into the sockets.
The middle (common) terminals for each level get soldered together. Once you have two rows (eight columns of four) assembled, you can connect the center conductors on each level. between the two rows. Then wire is used to connect each level to the correct "common" socket on the PCB. The bottom level doesn't need any wire because those middle leads are already in the center hole of the three pin socket. When wiring the layers going up, keep them in order according to which one is the bottom level (the center pins in the three pin sockets). The higher numbered layers (3 on one side and 7 on the other) are the bottom layers, so the lower numbered layers (0 and 4) should be wired to the top.
By now you have probably figured out there there are two "sides" to the cube that are basically wired separately from one another. Just do one side, get it working (make sure the IC is inserted and power the board up), and then replicate it for the other side.
The final effect is really worth the trouble.
4x4x4 LED Cube: Microcontroller and Source Code
If you are interested in reverse engineering the 4x4x4 LED cube, the microcontroller is based on the, once very common, 8051 chip. The variant used here is a STC12C5A60S2 (datasheet) in a 40 pin plastic DIP package.
There is a zip file available online with a schematic, all the source code (obviously not originally in English), and some other interesting information.
Congratulations!
You are now the master of all LED interfacing. Did you emerge victorious over the challenge of 3D soldering? Can you control the RGB Pixels and/or the FC-16 Matrix from a mobile device using Bluetooth? Did you create anything outside the box? If you enjoyed this Instrucable and you would like to have a box like this delivered right to your mailbox each month, please SUBSCRIBE HERE.
Please share your success (below or on the HackerBox Facebook page) and certainly let us know if you have any questions. Thank you for being part of the HackerBox adventure. Please keep your suggestions and feedback coming. HackerBoxes are YOUR boxes. Let's make something great!