Close
0%
0%

IoT RGB Led Cube 4x4x4 with Bluetooth

To dive a little deeper into eletronics and arduino programming, I created an 4x4x4 RGB Led Cube. Bluetooth is still to be done.

Similar projects worth following
I have been programming and tinkering with Arduinos or RPis for a long time but I never did anything more complex than reading sensors or creating my smart student room with 433 MHz radio switches ( http://chris-labs.de/hardware/raspberrypi/2013/10/10/raspberrypi-433mhz-switch-control.html ). All of this could be done with almost no electronic knowledge or any deeper understanding because the sensors involved were commonly used and libraries and schematics for them are all over the internet. But one day in late 2013 I stumbled over Kevin Darrahs Youtube videos on how he created an 8x8x8 RGB Cube ( http://www.kevindarrah.com/?cat=99 ). They are well done and he explains a great deal about the tricks and pitfalls of creating a RGB Cube. This really inspired me to build my own. The cube is already finished and working. What is missing now is a bluetooth module so I can control it over my mobile phone or make it available over the internet with my RPi.

Overview:

Here a short overview about the techniques and chips used in this project:

  • I used an arduino and shift registers to control the 192 LEDs ( the popular 74HC595 )
  • Shift registers can't handle the current of 8 bright LEDs so a Darlington Transistor Array was connected after the SRs (  ULN2803A )
  • I did not want to solder 192 pre-resistors and I wanted to have the option to change the resistance for each color later on so I soldered two DIP sockets in parallel after the darlington transistor array. Those sockets would be populated with the according Bourns Resistor Networks. This way I could switch resistors on the fly.
  • I used multiplexing. That means each of the four 4x4 layers is powered one after another. This way I only needed to control 4x4 = 16 RGB Leds (48 single LEDs) with the shift registers. Each layers anodes were switched with F9Z34N MOSFETs 
  • I used 5-Bit Angle Modulation to dimm the LEDs. It made the code a little more complex but there is no flickering now when fading from one color to another.
  • The Arduino is not soldered but plugged into a socket. This is because I want to add bluetooth connectability later. Once I got the bluetooth stuff figured out, I just plug a small PCB between the socket and the arduino (Whohoo extendable ;)
  • The PCB was DIY with the toner transfer method

The code and the circuit board layout can be found on GitHub: https://github.com/cgrossde/RGB-Led-Cube

This was my first time using eagle and designing a board, so don't expect it to be perfect. Also beware that the schematics miss some minor but important changes which were applied after the board was etched:

  • Added a diode for reverse polarity protection!!
  • Added a switch so the cube can be turned off
  • Power the Arduino only if the switch is on (e.g. connect 5V and GND after the switch with the Arduino)
  • This also makes sure that the Arduino does not try to power the whole circuit while programming it over USB

What needs to be done:

In order to connect the Cube to the "Internet of Things" and use it as a fancy representation of my mail box, or other stuff I need to add a bluetooth module to the design. I had extendability in mind when designing the cube and did not solder the arduino onto the board. Instead I used a socket to plug it in. Once I got the bluetooth magic figured out, I will create a small PCB with the bluetooth module and plug it between the socket and the Arduino. After that I will use my RPi as a middleman to connect it to the internet.


  • 1 × Arduino Nano v3.0
  • 64 × Bright Diffused Common Anode RGB LEDs The common anode part is important !!!
  • 7 × 74HC595 Shift register
  • 7 × ULN2803A Darlington Transistor Arrays
  • 4 × F9Z34N MOSFET One for every layer of 4x4 LEDs

View all 17 components

  • Prototype

    Chris02/07/2015 at 19:17 0 comments

    This was originally published on my blog: chris-labs.de


    This is the second part of my RGB-Cube series (here's the first) which describes my process of forming an idea to a working prototype. After spending hours of reading and ordering the first parts the project started to take shape and it was time for some serious prototyping. In the last part I described the different ways of controlling 192 LEDs and I decided to go with shift registers (SR). They are easy to control, have a low latency and there are no glitches like when you use Charlieplexing.

    After checking out some datasheets I decided to use the 74HC595 which has some nice convenience features:

    • Output-Enable: Turn all outputs off at once
    • Cascading: Serial output to chain multiple SRs together
    • Dedicated Storage Register: Fill the storage with data without impacting the output. Then use the latch to update the output.

    Problem: The 74HC959 however has a max. continuous current of only 35mA. One SR should control 8 LEDs which have a total current of 160mA (if they are all on at once). If we don't want to blow the SR we need something that can handle a little bit more current: Darlington Transistor Arrays (DTA). They are available as ICs and allow you to switch a higher current with a lower current. That means we put the DTA with 8 channels after the SR to avoid blowing our SR. The DTA model I chose was ULN2803A.

    Problem: Our circuit will be powered with 5V but LEDs don't like that. That's why we need resistors after the DTA. Since I'm a lazy person and I did not want to solder 192 resistors I searched online and found Bourns Resistor Networks. Essentially it's an IC with 8 pins on each side and a resistor in between. If you use IC sockets in your final PCB you get the added advantage of quickly changing resistors to adapt the brightness of your LEDs.

    Everything seems settled so now is a good time to print pin-outs of the ICs and grab a breadboard. Once that worked I wanted to create a PCB with one SR, one DTA and 8 LEDs just to make sure and to get some experience in the toner transfer method. After I figured out how to arange the ICs (SR on top, DTA on bottom) I used Eeagle to design the PCB. Use pull up / down resistors where necessary or your results might get very unpredictable. In my case I used a 10k resistor to pull OutputEnable high (disable output) and then set it low with the Arduino once I started to push some values into the SR.


    Using some SPI-Code on the Arduino I got the prototype working. Nice! I could have started now and use 24 SRs to control the LEDs but then every LED would have needed three dedicated wires (red-, green-, blue-kathode) and one shared anode. That would be one ugly Cube with a lot of wires. The solution for this problem will be discussed in my next blog post. But before I end this post one more step was needed to get a smooth LED-Cube: Determining the correct resistor for each color in the RGB-LED so that when all light up at once it gives a clean white. Use a breadboard for this and after that do yourself a favor and **test every singe RGB-LED you want to use**. They vary in brightness sometimes, so take a reference LED and test them all. I built a testing rig with three reference LEDs (one for each color) and a button for each of them. Then I attached the LED to test and pressed each button to compare the colors. To better judge the brightness you can put small paper hats ontop of the LEDs, also you won't get blind this way ;)


    Take aways of this post:

    • Use a darlington transitor array to protect your shift register
    • Use bourne resistor networks and IC-sockets to save soldering work and make your resistors exchangable
    • Use pull up / down resistors where necessary to avoid erratic behaviour
    • Test your LEDs for brightness
    • Find the correct resistor for each color so your RGB-LED is truly white

  • Planning

    Chris07/27/2014 at 21:11 0 comments

    There are lots of ways to build an LED Cube. Before you start, assess how many LEDs you want to control and how fast you need to refresh the state of your LEDs for dimming and animations. In my case I had a cube of 4x4x4 RGB LEDs which are in total 192 LEDs (64 for every color). I wanted to controle them with an Arduino Nano v3.0 which I had lying around. It turned out that there are not 192 pins on this Arduino, so we need a way to control all 192 LEDs with less pins.

    This is when you make your first design decision: Charlieplexing, Shiftregisters or LED-Driver-ICs ?


    Charliplexing: This allows you to control a lot of LEDs with a few IOs and some resistor. No other ICs needed. It's an intresting topic and you can read more here (http://en.wikipedia.org/wiki/Charlieplexing). But there are some drawbacks:

    • The refresh rate is low and charliplexed RGB Cubes tend to flicker
    • High peak current on single LEDs
    • Some LEDs can light dimmly when not desired
    • Complexity the bigger the matrix the more complex gets the circuit

    I wanted a nice and smooth RGB Cube and a low refresh rate and undesired light LEDs were not an option, so I discarded this method. If you got intrested check out this Instructable on how to build an 4x4x4 LED Cube.

    Shiftregisters: Shift registers allow you enter data in serial and output data in parallel. The most basic shift register has two inputs and several outputs. One input for data and another one for the clock. If you have a shift register with 8 outputs and want to set the first 4 outputs low and the last 4 outputs high you would do the following:

    • Put clock low and data high
    • Put clock high for a short amount of time
    • Now the first output is set high
    • Put the clock high and low three more times

    Now the first 4 Outputs are high, we are not done yet. Everytime you put the clock high for a short amount of time the shift register reads the data line. Then it shifts all outputs one up and sets the first output high or low depending on the data line. To get the desired state of our shift register( first 4 low, last 4 high) we need to set the data line low and clock the shift register 4 more times. This will shift the 4 high outputs to the end and enter 4 low outputs at the beginning. There is another example in the pictuer below, it sets the output to 10110111.

    Shift registers usually have some more features:

    A serial output line. After you put data in 8 times every new clock cycle will push one output state at the end of the shift register out to the serial output line. This allows you to chain multiple shift registers.

    Another feature is the output enable line. If you have 8 leds connected to a shift register and you want to put the first 4 low and the last 4 high. Then you need to shift 1111000 to the register. In the process you can observer that the first 4 leds start to light up and then move to the end of the line with every clock cycle. If you don't want to have the shift process you use the output enable line. You pull the output enable line low, and shift your 1111000 to the register. The output will not change until you put the output enable line high again. This way the shift process is not visible.

    If you use shift registers for your project you need some transistors after them because they cannot handle the current of several LEDs lit at once. This is why I used Darlington Transistor Arrays. They come as an IC and you don't have to solder a lot of single transistors and pull-up/down resistors to your board. After the transistor array you also need some pre-resistors depending on your LED (because they cannot handle 5V). If you are lazy like me, you buy Resistor Array ICs and put them in sockets. This way you can easyly solder the socket and exchange the resistor array later to adjust the brightness of your LEDs.

    LED-Driver-ICs: If you don't want to use Charlieplexing or shift registers then you could also use LED-Driver-ICs. They can be controlled like shift registers and...

    Read more »

View all 2 project logs

Enjoy this project?

Share

Discussions

Hari Wiguna wrote 07/29/2014 at 03:48 point
Maybe I missed it in Kevin's video. However,why is it called bit "angle" modulation? What angle?

  Are you sure? yes | no

Chris wrote 07/29/2014 at 09:37 point
I'm not sure,my best guess is, that it comes from analog angle/phase modulation which is used in transmitting data over radio. FM (frequency modulation) and PM (phase modulation). Once it all went digital someone might have remembered the principle and applied it to digital signals calling it BAM. Another, better term used for BAM is Binary Code Modulation.

  Are you sure? yes | no

Chris wrote 07/29/2014 at 09:42 point
Just found this http://www.artisticlicence.com/WebSiteMaster/App%20Notes/appnote011.pdf .
According to this PDF it was invented by Artistic Licence. It also describes other methods of dimming LEDs.

  Are you sure? yes | no

Hari Wiguna wrote 07/28/2014 at 01:57 point
I didn't know that resistor arrays were available in DIP packages. I soldered a header before and after the current resistors on my cube. Your way is much more elegant. I also need to learn about angle modulation for my 8x8x8 blue cube. Thank you for sharing.

  Are you sure? yes | no

Chris wrote 07/28/2014 at 13:38 point
Thanks for the comment. I sourced my resistor networks from Farnell ( bit.ly/Ux14g0 ). In the upcoming project logs I will cover bit angle modulation, so stay tuned ;) or if you can't wait check out Kevin's excellent Youtube video about it ( https://www.youtube.com/watch?v=I0sgqgUwIAQ )

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates