Introduction: 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!

Step 1: 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

Step 2: 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.

Step 3: 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.

Step 4: 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.

Step 5: 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.

Step 6: 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

Step 7: 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.

Step 8: 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.

Step 9: 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.

Step 10: 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.

Step 11: 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!

Comments

author
Cabalist made it! (author)2016-05-10

For those having issues with unsigned CH340/41 drivers on OS X 10.11 the latest drivers on the chinese site are signed and working.

http://www.wch.cn/download/CH341SER_MAC_ZIP.html

Just hit the download button. This is the manufacturer of the USB-to-Serial chip.

author
ChrisAu made it! (author)2016-04-03

anyone figure out if it's programible yet?

temp_720469003.jpg
author
HackerBoxes made it! (author)HackerBoxes2016-04-04

That looks great! Yes, we’ve added a new “Step 10” into these instruction with pointers to the schematic, all the source code, and some other interesting technical details for anyone curious about reverse engineering or modding the 4x4x4 LED cube. Check it out!

author
rgm3 made it! (author)rgm32016-04-30

I'm starting to suspect that the source you provided is for a single color version of this kit. As soon as i flash the supplied hex file my red leds stop working.

author
rgm3 made it! (author)rgm32016-04-16

Yes, I put some info up on github. Check my other comment for the link. I accidentally fried pins 38 and 39 trying to get into bootloader mode, so I'm waiting on a replacement microcontroller before I give more accurate names to the functions.

author
YegM made it! (author)2016-04-17

Hello, I'm getting ready to solder the first parts onto the circuit board. I noticed there are 3 capacitors but I only can find two (c2 and c3) for these on the circuit board, but cant find c1, anyone know where c1 is located? I cant find it on the circuit board.

author
rgm3 made it! (author)rgm32016-04-19

This confused me too. There's an extra small capacitor. You only need the two next to the crystal. I checked the schematic to be sure.

author
YegM made it! (author)YegM2016-04-20

Thanks for the reply. I wasn't sure either, but I wanted to make sure I wasn't missing something. I guess we get a 22pF cap for free them :)

author
rgm3 made it! (author)2016-04-16

I had success programming the cube on Linux, and I'm pretty sure it'd be easy on Mac OS X too. Pull requests welcome!

https://github.com/rgm3/ledcube444

author
StephenK74 made it! (author)2016-04-14

The HC-05 was great, I installed it into my Megasquirt EFI no more serial cable outside of flashing the firmware!

author
rgm3 made it! (author)2016-04-12

I used blu-tak to hold the LEDs down on a piece of paper with 2cm ruler marks while soldering the cube together. The red common wires in order of short-medium-long (for layers 2-3-4) on J7 are P26, P25, P24. On J6 it's physically the same order, P22 (short wire, layer 2 cathode), P21 (medium), P20 (long). I don't understand how these LEDs are current limited -- the 4 1k resistors seem to be only for the color changing LEDs underneath? The chinese source code files are Windows-1252 versions of gb2312 encoded data.

author
park_ind_ent made it! (author)2016-04-10

Put my 4x4x4 in a plastic case (http://www.containerstore.com/s/clear-flush-lid-amac-boxes/d?productId=10028594) to keep it safe after all that soldering. I drilled four holes in the lid to align with the standoffs. I then screw the cube to the lid (Using the box upside down). Cut a hole to allow the power cable to go in and done.

WP_20160410_001.jpgWP_20160410_002.jpgWP_20160410_003.jpg
author
Brent_N_Charlie made it! (author)2016-04-02

Trying to connect HC-05 to arduino board, while keeping the FC-16 also attached. Can't connect both to the 5V/GND to arduino. Please help this newbie...

author
OrangeKat made it! (author)OrangeKat2016-04-03

I *think* that you are saying that because there is only on 5V pin on the Arduino that you can't connect both. Is that right? If so, you need to use a breadboard or create your own wire that splits to allow voltage to both. If that was not what you were asking, I am not understanding the question.

author
Brent_N_Charlie made it! (author)Brent_N_Charlie2016-04-05

Yes that answers my question - thanks for the response. I also read elsewhere that the IOREF can also be used as a passthrough for the 5V supply and that worked for us.

author
djcc2012 made it! (author)djcc20122016-04-06

Thanks Brent_N_Charlie! I had the same question. Using IOREF works great. Changing the matrix scroll using the Bluetooth via my phone is very cool.

author
Cabalist made it! (author)2016-04-04

Thanks for posting the code! Looks pretty straightforward

IMG_0479.JPG
author
HackerBoxes made it! (author)HackerBoxes2016-04-04

Another fine piece of soldering work. Have fun showing that beauty off! :)

author
AdamP95 made it! (author)2016-04-01

I am having trouble getting the HC-05 to stay connected to my phone. At best I can get connected for a few moments, but as soon as I try to do anything in BlueTerm it disconnects. The red LED on the HC-05 keeps blinking quickly on and off, but does not stay on. When I try to connect the blinking changes to two blinks, then off for about 1 second and repeats until it disconnects. I have paired the HC-05 using the android bluetooth connection. Any advice?

author
HackerBoxes made it! (author)HackerBoxes2016-04-01

Hello Adam. One thing to check is the power supply. The HC-05 uses a lot of power. Make sure you have a solid connection to VCC. Are you powering the HC-05 from the Arduino board? A second possibility is some glitch with the app you are using. I've read of people having to switch to a different bluetooth app (in this case bluetooth terminal) to maintain a solid connected state. Hopefully one of these helps to solve the problem.

author
AdamP95 made it! (author)AdamP952016-04-04

This was my problem thanks! I hooked everything up to a bread board instead of directly to the arduino and have had success. Sometimes there is a long (~2 minutes) before what I enter into BlueTerm displays but I was also messing with other apps on my phone at the same which I think messed things up.

Thanks for the fun kit and projects!

author
HackerBoxes made it! (author)HackerBoxes2016-04-04

Hey Adam. We are glad that helped and very happy to hear that you are enjoying the kits and projects. We have much more in store! :)

author
HackerBoxes made it! (author)2016-04-04

Anyone curious about reverse engineering or modding the 4x4x4 LED Cube, check it out! We’ve added a new “Step 10” into these instruction with pointers to the schematic, all the source code, and some other interesting technical details.

author
park_ind_ent made it! (author)2016-04-02

For the windows phone users out there, Bluetooth Agent by Elvin works well to communicate with the HC-05. Make sure to adjust the settings in the app accordingly. Message protocol should be: DataEndsWithSuffix and Message suffix should be: \n.

author
ColinH44 made it! (author)2016-04-02

Hi there,

I'm having an issue with editing the MD_MAX72xx.h file in the src folder to get the example files that are used to power the scrolling display. I tried to open it in notepad, but all I got was a wall of text describing the functions of the display unit. Do you extract all the files in the Parola and the MD_MAX72XX folders directly into the libraries folder, or is there something else I haven't thought of?

Thanks,

-CSH

author
HackerBoxes made it! (author)HackerBoxes2016-04-02

Yes, you unzip the downloaded library file and it will expand into a folder called MD_MAX72XX which has four files in it as well as four folders (one being src). Put that entire folder (with everything in it) into the libraries folder under your Arduino IDE installation. The header file you have to edit is in the src folder. You also do this same thing with the MD_Parola library zip. Parola has an examples folder having several sketches that you can play around with (including Parola_HelloWorld). FYI, there are various tutorials online for adding libraries to the Arduino IDE if that is causing any trouble.

author
PhillipG8 made it! (author)2016-04-01

The 4x4x4 LED grid took forever to solder. Breaking it into multiple sessions really is the way to go. Does anyone know where you could find the source code? The demo is fun, but I would rather control is myself.

20160401_232920.jpg
author
HackerBoxes made it! (author)HackerBoxes2016-04-01

The code (obviously not originally in English) is in this zip file:
http://www.icstation.com/ebay/IC/All%20data%20modules/4681.zip

Here is a datasheet for the CPU (STC12C5A60S2):
http://www.stcmcu.com/datasheet/stc/stc-ad-pdf/stc12c5a60s2-english.pdf

That chip is based on the 8051 which used to be a super common microcontroller:
https://en.wikipedia.org/wiki/Intel_MCS-51

author
TimGTech made it! (author)2016-03-28

Here is a link to get the CH340 USB drivers for the Arduino board in this haxerbox.

http://0xcf.com/2015/03/13/chinese-arduinos-with-c...

author
robie1373 made it! (author)robie13732016-03-31

Unless things have changed in the last month or so, there is no signed driver for this chip for OS X. As of 10.11 (I think) that means there is no sane way of using it. In 10.10 you could disable signed driver checking if you were brave enough. That is gone in 10.11

author
HackerBoxes made it! (author)HackerBoxes2016-03-31

There is a work around...
https://tzapu.com/making-ch340-ch341-serial-adapters-work-under-el-capitan-os-x/

author
robie1373 made it! (author)robie13732016-04-01

Yea. That's what I meant by no "sane" way. As annoying as it is, there are very good reasons apple made this change. Turning off driver signing is a no-go for me.

author
TimGTech made it! (author)2016-03-29

OK this is weird! I am playing with the LED Matrix display. Got the libraries loaded and uploaded the "Hello" example sketch. It's all garbled so I tried one character at a time and it's fine but "Hello" is garbled. Here's where it gets weird - if I spell my name with spaces between the letters I get "T I M" Correct! If I do "TIM" I get ITM. Huh!?!?!

author
HackerBoxes made it! (author)HackerBoxes2016-03-29

Hi Tim! Did you make the change to the MD_MAX72xx.h file? It sounds like the library might not be using the FC-16 setup.

author
TimGTech made it! (author)TimGTech2016-03-29

That was it! I did change it though. Long story short - I have multiple versions of the Arduino IDE and Libraries in different places. I ended up with the libraries in two different places. The one I changed was not the one it was loading. User error from having too many shortcuts to too many places on my desktop. I'm glad that's all it was. I thought I was loosing my mind! I was just loading the unchanged library and didn't realize it. THANKS!! :)

WP_20160329_004.jpg
author
TimGTech made it! (author)TimGTech2016-03-29

Here is what I get if I do "AB" and "123" in the Hello example. Backwards?

WP_20160329_001.jpgWP_20160329_002.jpg
author
HackerBoxes made it! (author)2016-03-29

It looks like the text and links for the Bluetooth module didn't get posted correctly on the first day. They should be alright now. Thanks for pointing that out. Sorry for any confusion.

author
zal42 made it! (author)2016-03-29

That 4x4 cube is a TON of soldering, but I enjoyed it more than I thought. Very meditative. And the result is absolutely spectacular. Lots of goodies this month! Thank you!

The Hackerbox info on the Bluetooth module is a little skimpy, but detailed info can be found here:

https://arduino-info.wikispaces.com/BlueTooth-HC05...

author
Cabalist made it! (author)2016-03-28

"and the found round LEDs." should be "and the four round LEDs."

About This Instructable

8,967views

28favorites

License:

More by HackerBoxes:HackerBoxes 0021: Hacker TrackerHackerBoxes 0020: Summer CampHackerBoxes 0019: Raspberry WiFi
Add instructable to: