Saturday 23 February 2013

3x3x3 LED Cube

I had a day of nothing to do (makes a change) today and after seeing some pretty awesome LED cubes on YouTube, I though I'd give it a go. Unfortunately, I only had 9 green LEDs and I needed 27. There's a pretty obvious problem there so I had to make a quick trip to the nearest Maplin to pick up a load more and a few resistors.

To make the cube, I needed to make the 3 layers of LEDs first. To do this, I made a jig. My jig consisted of a bit of wood with holes drilled in where the LEDs will sit while soldering. To do this, I opened SolidWorks and created my jig template.


I then printed this out on a 1:1 scale, and stuck it on top of a piece of scrap wood and drilled the 5mm holes.



I also drew on arrows as to which way each of the LED cathodes would be pointing. The cathode on an LED is the negative leg, definable by a segment of of the circular shape of the LED cut off, or by the shorter leg. I pushed all the LEDs into the jig, bent the legs and soldered then together.


When pushed out...


To make sure all of my connections worked, I used 2 1.5V AA batteries, connected one lead to the ring of cathodes, and used the other lead to connect to each of the anodes (positive longer leg) in turn to check they all worked.


Once I had made all 3 layers, and tested each, it was time to assemble the cube, and that, was not an easy job by any means. It took rather a long time and a lot of crocodile clips... but it finally came together.


And worked...


There was however a big problem with using the Pi to control it, the Pi has 7 GPIO pins for me to use for this, and I needed 12. One for each column of LEDs and one for each layer. I only have on face of LEDs working at the moment, using 6 pins (I might have to move this project onto an Arduino at a later date..) The 9 LEDs that I am using I have programmed to move in an S shape repeatedly. With every LED cube out there, you can only ever have 1 LED on at any set time. To make more appear on, you have to flash the LEDs on and off faster than the eye can detect. This also works on 1 face with 6 pins.

To control only 1 LED without turning the others on, the positive AND ground need to be turned on as needed to light the desired LED. I used 3 NPN BC547B transistors and 3 22kΩ resistors to turn ground on and off on each layer, and each of the 3 columns of LEDs I was using went straight onto the GPIO (they could do protection by resistors really). It all went on to my breadboard.



Jamie

6 comments:

  1. Hi, nice project. What LEDs do you use?

    ReplyDelete
    Replies
    1. Thanks :) I used standard green LEDs that you can get in a multipack from Maplin because it was close and quick. You can use pretty much any LEDs you want, even RGB ones. If you have RGB ones or more than 3x3x3 you'll need an LED driver. Have fun making one!

      Delete
  2. hi can you provide the source code for the 2x2x2 led cube?

    ReplyDelete
    Replies
    1. I have the (rather messy and not optimal) code I wrote quickly for Arduino over at my GitHub ( https://github.com/Jamie-/LEDCube ) but if you want code to run this 2x2x2 (8 LEDs) then that will work fine, just remove some bits. If you want code to run it on the Pi though then let me know and I'll quickly write some for a 2x2x2.

      Delete
    2. I would really appreciate if you provide the raspberry pi code for
      2x2x2 led cube (8 leds).

      Delete

Thanks for your comment! If it's a query or question, I'll try to get back to you as soon as I can. I hope this blog has helped or inspired you!