Step 70: Run the cube on an Arduino

Since we published our last LED Cube instructable, we have gotten a lot of questions from people wondering if they could use an Arduino to control the cube.

This time, we are one step ahead of you on the "Can i use an arduino?" front :D

The IO requirements for an 8x8x8 LED cube is:

  • Layer select: 8
  • Data bus for latches: 8
  • Address bus for latches: 3
  • Output enable (OE) for latches: 1

Total: 21

The Arduino has 13 GPIO pins and 8 analog inputs, which can also be used as GPIO. This gives you a total of 21 IO lines, exactly the amount of IO needed to run the LED cube!

But why write about it when we could just show you?

We hooked the cube up to an Arduino and ported some of the software.

Since the multiplexer array and AVR board are separated by a ribbon cable, connecting the IO lines to an Arduino is a simple matter of connecting some breadboard wires. Luckily, we soldered in a female 0.1" pin header for the transistor lines when we were debugging the first set of transistors. Just remove the ATmega and connect wires from the Arduino to these pin headers.

We connected the cube like this: DATA bus: Digital pins 0-7. This corresponds to PORTD on the ATmega328 on the Arduino board, so we can use direct port access instead of Arduinos digitalWrite (which is slow). Address bus: Digital pins 8-10. This corresponds to PORTB bit 0-2. On this we HAVE to use direct port access. Arduinos digitalWrite wouldn't work with this, because you can't set multiple pins simultaneously. If the address pins are not set at the exact same time, the output of the 74HC138 would trigger the wrong latches. Output Enable: Digital pin 11. Layer transistors: Analog pins 0-5 and digital pins 12 and 13.

We had to go a bit outside the scope of the Arduino platform. The intention of Arduino is to use digitalWrite() for IO port access, to make the code portable and some other reasons. We had to sidestep that and access the ports directly. In addition to that, we had to use one of the timers for the interrupt routine.

The registers for the interrupt and timers are different on different AVR models, so the code may not be portable between different versions of the Arduino board.

The code for our quick Arduino hack is attached.

<p>Great work..</p>
Hii....i built my cube but its not glowing properly....
<br> The<br> website is looking bit flashy and it catches the visitors eyes. Design is<br> pretty simple and a good user friendly interface.<br><p><a href="http://journalistesportif.tumblr.com" rel="nofollow">http://journalistesportif.tumblr.com</a></p>
<p>Hi, I've added your project to the &quot;<strong>A Collection of WAAAY To Many 8X8X8 RGB LED Cubes!</strong>&quot; Collection</p><p>This is the link If you are interested:</p><p><a href="http://www.instructables.com/id/A-Collection-of-WAAAY-To-Many-8X8X8-RGB-LED-Cubes/">http://www.instructables.com/id/A-Collection-of-WA...</a></p>
<p>Hi guys! ? </p><p>first, thanks to chr for that incredible instructable! it has me inspired, a lot. </p><p>i tried to download the files from the project. but i was not successfull.</p><p>any ideas?</p>
<br> <a href="http://damdaar.com/14-major-incidents-by-global-warming-climate-changes/" rel="nofollow">hardly heat waves in Argentina</a><br>
<p>I tried it, but failed to glow all...</p>
<p>Good work...</p>
<p>hi all</p><p>As like &quot;<a href="http://www.instructables.com/member/power000" rel="nofollow">power000</a>&quot; my led cube also having da same problem, some led column remain on constantly, pls help &amp; suggest the reason and how to rectify the problem.</p>
<p>go to my revisited instructable and get my code or go to <a href="http://www.TheLEDCube.com"> www.TheLEDCube.com </a> and download the RAMP.zip file, and upload my code to your cube.</p><p>Video the POWER ON SELF TEST and send me a message with a link to your video, and I will diagnose your issue.</p>
<p>Hi, I seem to have successfully set the fuse bits, but here's the thing: after uploading the test.hex file to atmega32 and turning the cube on i get some random layers light up and stay on (with some flickering). Here's the video of that: <a href="https://www.dropbox.com/s/qpha7qhs9xkwyb8/VID_20151030_185558.mp4?dl=0" rel="nofollow">https://www.dropbox.com/s/qpha7qhs9xkwyb8/VID_2015...</a></p><p>I have a suspicion, that i may have fried something on the board and i hope that you may have an answer to that. At one point, i have accidentally powered on the cube via the 5V power source while it was still connected to USBasp which was plugged in the usb port. The USBasp didn't work afterwards (lol), so i ordered a new one. I also had trouble connecting to the atmega via the on-board connector, so i put it on a breadboard to see if it makes a difference - still no go. But after adding the crystal and two 22pF capacitors on the XTAL1 and XTAL2 SUCCESS! Avrdude started displaying the correct signature, i managed to set the fuse bits and write the test.hex successfully into the atmega. Do you have any idea if i could tinker with a multimeter to see whether anything went bad? Oh, i had a 1A fuse installed, which went off during my &quot;accident&quot;.</p><p>Thank you in advance!</p><p>P.S. I'm thinking of upgrading my cube in the long run by purchasing one of your premade boards to eliminate the wiring. However, I'm confused on which one i should get and how much that would cost me.</p>
<p>One of the fuses you set initially is switching from the internal 4MHz clock to the external crystal - so no crystal = no running after setting the fuses...that is until you add the crystal. So chances are, you didn't damage anything. In fact it did exactly what one would expect. For a mono cube, you'll want one of the RAMP boards.</p>
<p>So basically what you're saying is that atmega is not &quot;seeing&quot; the external crystal?</p>
<p>No, what I am saying is it never looks for the crystal UNTIL you set the fuse bits.</p><p>Once they are set, it MUST have a crystal.</p><p>No crystal means no clock, and a CPU running at zero clock cycles won't get much done! That's why it sprang to life once you added the crystal.</p>
<p>I finally got test.hex flashed and it works..sort of (video here: https://www.dropbox.com/s/5kophve403vw5cr/VID_2015...</p><p>I was happy nonetheless, because the sequence runs nicely with a few exceptions:</p><p>1. There must be a wiring issue, because the rows go like this: 1, 2, 4, 3, 6, 5, 7, 8. I tried tinkering with the wires to no avail, i don't really understand what could be causing this. I'm thinking maybe transistors?</p><p>2. The flickering and unlit LEDs must be caused by soldering errors or lack of contact, am I right?</p><p>3. There are some LEDs which faintly glows when turned off (itcan be seen when the whole cube goes dark). Does it mean that those LEDs receive some of the current even in the off state?</p>
<p>You may have the last 2 bits of the demultiplexer reversed....</p><p>so instead of bits A0, A1, A2 you have them wired bits A0, A2, A1. (as I recall, these would be pins 2 and 3 of the 74HC138) This might explain the sequence.</p><p>Triple check your wiring to the 138</p><p>Also you might have the data bus wired wrong, or you may simply have wired the cube to the controller incorrectly.</p><p>Your dropbox link isn't working, maybe try to youtube it.</p>
<p>Ok, thanks, I'll try that. </p><p>Here's link to youtube: <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/nvisYO6vk0E" width="500"></iframe></p>
<p>looks more like a wiring issue from controller to cube than demultiplexer issue.</p><p>try the main.hex from <a href="http://www.instructables.com/id/CHRs-8X8X8-LED-Cube-Revisited-with-improvements/step10/How-do-I-modify-the-software-Questions-Answers-and/">http://www.instructables.com/id/CHRs-8X8X8-LED-Cub...</a> </p><p>I think that has my power on self test, which I would like you to video. It will tell me in better detail what's wrong with your cube.</p>
<p>main.hex video here:</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/las1Agjynrc" width="500"></iframe></p><p>Very nice sequence, can't stop watching the cube!</p>
<p>I tried to transfer the correct code to you by skype, but you never came back online.</p>
Thanks for your time. Sorry I didn't have the time for that, I'm studying in college and working night shifts, so free time is scarce :D after placing the pcb boards with the wiring on a stable surface (the boards were just placed beneath the cube without any extra support) and running the cube for several hours I've noticed an improvement in terms of flickering and missing LEDs. There's still one part that is flickering, but I believe I'll manage that. Also, after flashing this main.hex file I noticed that the sequence runs in order (maybe the test.hex had it's flaws?). So, apart 2 burned LEDs and some minor flickering during certain animation I find the cube in an OK condition, requiring minor tweaks. So I don't really want to bother you with such minor problems. I'd appreciate any .hex files you can throw my way though. Many thanks, I'll keep in touch!
<p>OK, but remember you won't get any text unril you also flash the MAIN.EEP. both the eep and the hex need to be flashed to the chip to get the text, otherwise all the letters will appear as solid blocks.</p>
Alright, but if I remember correctly, I have to use rs232 connector? I have a slight problem with that, because my computer doesn't have the serial port (db9).
<p>nope. You know those squares that go around the outside of the cube right now? Those are actually undefined letters.</p>
<p>crap, that's the old main.hex....I'll have to compile one for you that has the power on self test. However, in the mean time...you do seem to have some short circuits, and you seem to have some of the lines wired wrong. I'll PM you my skype address, and I'll try to have a video session with you. Add me to your skype.</p>
<p>...sorry, can I impement this Code<br>(RAMP.zip) in Arduino UNO??? it&acute;s the same?? I have looked at:<br><a href="http://www.TheLEDCube.com/" rel="nofollow">www.TheLEDCube.com</a> but I<br>haven&acute;t seen it, in which section it is? I can&acute;t see it...Many<br>thanks! </p>
<p>At the top of the main page, click SOURCE CODE then download RAMP.ZIP</p><p>Unzip the file to a folder on your hard disk / desktop.</p><p>The source code for the Arduino is in the Atmega 328 section/folder.</p><p>Because my board conforms 100% to this project on both the Atmega328P (Arduino) and the ATmega32, I include code for both processors.</p><p>Please remember that with the Arduino, you lose serial capabilities (and on my boards, you also lose music response)</p>
<p>...I think got it!, do you think is this file: &quot;8X8X8 Arduino.pde&quot;?</p>
<p>that one or the one WITH POST (Power On Self Test)</p>
<p>...which one, which one? (do you mean this instructable publication you <br>are recomending me?) and where can I see the one with POST (Power On Self Test) you said? Sorry this instructable publication is yours, or you <br>post it? Many thanks!!!</p>
<p>You can use either code. If you downloaded the RAMP mini-CD then the code with POST is in a subdirectory where the regular arduino code is.</p><p>This instructable is not mine, it's one I post in. This was the instructable that got me into microcontrollers and LED cubes. TheLEDCube.com is my site where I offer PC Boards and extended code for this and the RGB LED cube projects.</p><p>Please don't expect people to tell you what to do every step of the way. Try to explore and READ and figure things out on your own. If you have a question that is BEYOND all the documentation, then we are here to help.</p>
<p>Yes sorry!!! Many thanks I will ;D</p>
<p>...mmm wow, I like Arduino because it seems less work to do, but so which circuit is the best or more complete to do? The one of Instructables? &amp; sorry serial capabilities for what? what can I do with that?</p>
<p>To answer all your questions, please finish reading this complete instructable, and then go through my &quot;revisited&quot; instructable.</p>
<br> This is<br> such a great resource that you are providing and you give it away for free. I<br> love seeing blog that understand the value. Im glad to have found this post<br> as its such an interesting one! I am always on the lookout for quality posts<br> and articles so i suppose im lucky to have found this! I hope you will be<br> adding more in the future...<br><br> <a href="https://www.youtube.com/watch?v=ZyF8T0eOYqc" rel="nofollow">Genius marketing pro review </a><br>
<p>Hi, </p><p>Thanks a lot for this instructable, i finished building the cube and it works almost perfecly. The only issue is that when the cube wants to show the first data of the fifth IC(547) it turns all the plane on. i've checked the continuity between all the data lines as well as changing the IC, but none of this worked. I would really aprecciate your help since i don t know what else to do.</p><p>(By the way i&acute;m using an Arduino UNO and it's a 7x7x7 cube).</p>
<br> This was<br> a really great contest and hopefully I can attend the next one. It was alot<br> of fun and I really enjoyed myself..<br><br> <a href="https://www.youtube.com/watch?v=aUuMyaPyby4" rel="nofollow">Build my list 2.0 review</a><br>
<br> Greatpost, you have pointed out somefantasticpoints , Ilikewisethinkthis s a verywonderful<br> website.<br><br> <a href="https://www.youtube.com/watch?v=2OKOGM3JYCc" rel="nofollow">Build my list 2.0 bonus</a><br>
<p>Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. <a href="https://www.youtube.com/watch?v=6XvjFwRywZU" rel="nofollow">Commission Juggernaut Reloaded</a></p>
<br> I felt<br> very happy while reading this site. This was really very informative site for<br> me. I really liked it. This was really a cordial post. Thanks a lot!.<br><br> <a href="http://lagrill.co.ukhttp://lagrill.co.uk" rel="nofollow">restaurants in sutton coldfield</a><br>
<br> howdy,<br> your websites are really good. I appreciate your work.<br><br> <a href="http://vertshocked.net" rel="nofollow">how to improve a vertical jump</a><br>
<br> Hey There. I found<br> your blog using msn. This is a very well written article. I&rsquo;ll be sure to<br> bookmark it and come back to read more of your useful info. Thanks for the<br> post. I&rsquo;ll definitely return.<br><br> <a href="https://www.youtube.com/watch?v=BbRyrYF0NmQ" rel="nofollow">ecom premier academy review</a><br>
<br> If you set out to<br> make me think today; mission accomplished!I really like your writing style and how you express your ideas.Thank you.<br><br> <a href="https://www.youtube.com/watch?v=BbRyrYF0NmQ" rel="nofollow">ecom premier academy review</a><br>
<br> I have been<br> checking out a few of your stories and i can state pretty good stuff. I will<br> definitely bookmark your blog<br><br> <a href="https://www.youtube.com/watch?v=YRB6IfTZkGc" rel="nofollow">The Venus Factor Review</a><br>
<p>I am not using rs232 ic just using atmega32 and 74hc574and 74hc138ic just using basic module I don want confuse I want program the atmega working alone </p>
<p>check my &quot;revisited&quot; instructable.</p>
<p>Is it just me, or did all the comments disappear?</p>
<p>Finally, they are back!</p>
<p>I wish I could make this, but the instructions are so complex that it makes me feel like a failure at life even though I have a degree in physics.</p>
<p>You may wish to try my PCBs then. </p><p>Go to www.TheLEDCube.com for everything you need to easily build this otherwise daunting project.</p>

About This Instructable


3,632 favorites


Bio: I like microcontrollers and LEDs :D
More by chr: Reverse Engineering: RGB LED Bulb with IR remote Reverse engineering: USB controlled home automation hack LED Cube 8x8x8
Add instructable to: