Introduction: Custom Animation for 3x3x3 Led Cube

The following is run off of the arduino uno. I am publishing this as a beginner for beginners. this script should teach you how to control individual leds in the cube and show you what needs to be scripted to allow animation.

I am not certain that this is the easiest way to do this as I just modified the "Box diamond" portion of the LEDCUBE script.



NOTE: the below comes from importing the LedCube library which can be found at this instructable
https://www.instructables.com/id/LED-Cube-and-Arduino-Lib/?ALLSTEPS

the script is as follows (cut and paste everything after this into your arduino script editor)

#include


//This is just a little something, Notice I stay off of LED's 0,7, and 0,6, that is because I could not get them to be controlled. They are in working condition,
//but despite my best efforts I could not control whether they turned off or on. 0,7, just stays dimly lit and 0,6, does nothing. (mind you they both are in working condition)
#define SIZE 3
#define COLS (SIZE*SIZE)

byte levelPins[SIZE] = {11,12,13};
byte colPins[COLS] = {2,3,4,5,6,7,8,9,10};

LedCube cube(3, levelPins, colPins);

void setup ()
{
//    Serial.begin(9600);
}

void loop ()
{
    delay(250);
    cube.enableBuffer(false);
   
   
    //NOTE: byte x [] = {layer,column,}; they run in sequence starting at #0(lowest layer/first column)
   
   
// a through f draws the letter o
byte a [] = {0,0, };
byte b [] = {0,0, 1,0, };
byte c [] = {0,0, 1,0, 2,0, };
byte d [] = {0,0, 1,0, 2,0, 2,1, };
byte e [] = {0,0, 1,0, 2,0, 2,1, 2,2, };
byte ee [] ={0,0, 1,0, 2,0, 2,1, 2,2, 1,2, };
byte f [] = {0,0, 1,0, 2,0, 2,1, 2,2, 1,2, 0,2, };
// pushes the letter around the cube
byte g [] = {0,0, 1,0, 2,0, 2,1, 2,2, 1,2, 0,2, 0,1, };
byte h [] = {0,1, 0,2, 1,1, 2,1, 2,2, 0,5, 1,5, 2,5, };
byte i [] = {0,2, 1,2, 2,2, 0,5, 2,5, 0,8, 1,8, 2,8, };
byte j [] = {1,2, 1,5, 1,8, 2,2, 2,8, 2,1, 2,4, 2,7, };
byte k [] = {2,2, 2,5, 2,8, 2,1, 2,7, 2,0, 2,3, 2,6, };
byte l [] = {2,6, 2,7, 2,8, 1,3, 1,5, 1,0, 1,1, 1,2, };
byte m [] = {2,6, 2,7, 2,8, 1,3, 1,5, 0,0, 0,1, 0,2, };
byte n [] = {2,3, 2,4, 2,5, 1,3, 1,5, 0,3, 0,4, 0,5, };
// puts letter back at beginning
byte o [] = {2,0, 2,1, 2,2, 1,2, 1,5, 0,3, 0,4, 0,5, };
byte p [] = {0,0, 1,0, 2,0, 2,1, 2,2, 1,2, 0,2, 0,1, };
// letter erases
byte q [] = {0,0, 1,0, 2,0, 2,1, 2,2, 1,2, 0,2, };
byte r [] = {0,0, 1,0, 2,0, 2,1, 2,2, 1,2, };
byte s [] = {0,0, 1,0, 2,0, 2,1, 2,2, };
byte t [] = {0,0, 1,0, 2,0, 2,1, };
byte u [] = {0,0, 1,0, 2,0, };
byte v [] = {0,0, 1,0, };
byte w [] = {0,0, };
byte x [] = {};
byte y [] = {};
byte z [] = {};

//for weeble wobble
byte aa [] = {2,2, 2,5, 2,8, 2,1, 2,7, 2,0, 2,3, 2,6, };
byte bb [] = {2,0, 2,1, 2,2, 2,3, 2,6, 1,8, };
byte cc [] = {2,0, 2,1, 2,2, 2,5, 2,8, 1,6, };
byte dd [] = {2,8, 2,2, 2,5, 2,6, 2,7, 1,0, };
byte ff [] = {2,0, 2,8, 2,3, 2,6, 2,7, 1,2, };
byte gg [] = {};
byte hh [] = {2,0, 2,1, 2,2, 2,3, 2,6, 1,8, };
byte ii [] = {2,0, 2,1, 2,2, 2,5, 2,8, 1,6, };
byte jj [] = {2,8, 2,2, 2,5, 2,6, 2,7, 1,0, };
byte kk [] = {2,0, 2,8, 2,3, 2,6, 2,7, 1,2, };
byte ll [] = {};
byte mm [] = {2,0, 2,1, 2,2, 2,3, 2,6, 1,8, };
byte nn [] = {2,0, 2,1, 2,2, 2,5, 2,8, 1,6, };
byte oo [] = {2,8, 2,2, 2,5, 2,6, 2,7, 1,0, };
byte pp [] = {2,0, 2,8, 2,3, 2,6, 2,7, 1,2, };
byte qq [] = {};
byte rr [] = {2,0, 2,1, 2,2, 2,3, 2,7, 1,8, };
byte ss [] = {2,0, 2,1, 2,2, 2,5, 2,8, 1,6, };
byte tt [] = {2,8, 2,2, 2,5, 2,6, 2,7, 1,0, };
byte uu [] = {2,0, 2,8, 2,3, 2,6, 2,7, 1,2, };
byte vv [] = {2,2, 2,5, 2,8, 2,1, 2,7, 2,0, 2,3, 2,6, };
byte ww [] = {2,0, 2,1, 2,2, 1,2, 1,5, 0,3, 0,4, 0,5, };
byte xx [] = {0,0, 1,0, 2,0, 2,1, 2,2, 1,2, 0,2, 0,1, };
byte yy [] = {};
byte zz [] = {};
//helicopter
byte aaa [] = {2,4, 2,1, 2,7, };
byte bbb [] = {2,4, 2,2, 2,6, };
byte ccc [] = {2,5, 2,3, };
byte ddd [] = {2,4, 2,8, 2,0, };
byte eee [] = {2,4, 2,1, 2,7, };
byte fff [] = {2,4, 2,2, 2,6, };
byte ggg [] = {2,5, 2,3, };
byte hhh [] = {2,4, 2,8, 2,0, };
byte iii [] = {2,4, 2,1, 2,7, };
byte jjj [] = {2,4, 2,2, 2,6, };
byte kkk [] = {2,5, 2,3, };
byte lll [] = {2,4, 2,8, 2,0, };
byte mmm [] = {2,4, 2,1, 2,7, };
byte nnn [] = {2,4, 2,2, 2,6, };
byte ooo [] = {2,5, 2,3, };
byte ppp [] = {2,4, 2,8, 2,0, };
byte qqq [] = {2,4, 2,1, 2,7, };
byte rrr [] = {2,4, 2,2, 2,6, };
byte sss [] = {2,5, 2,3, };
byte ttt [] = {2,4, 2,8, 2,0, };
byte uuu [] = {2,4, 2,1, 2,7, };
byte vvv [] = {2,4, 2,2, 2,6, };
byte www [] = {2,5, 2,3, };
byte xxx [] = {2,4, 2,8, 2,0, };
byte yyy [] = {2,4, };
byte zzz [] = {2,4, };


         //NOTE: cube.lightSequence(*whichever byte you are referring to* sizeof(*that byte*), *how long you want to stay lit*);


//for the letter sequence
    cube.lightSequence(a, sizeof(a), 500);
     cube.lightSequence(b, sizeof(b), 500);
      cube.lightSequence(c, sizeof(c), 500);
       cube.lightSequence(d, sizeof(d), 500);
        cube.lightSequence(e, sizeof(e), 500);
         cube.lightSequence(ee, sizeof(ee), 500);
         cube.lightSequence(f, sizeof(f), 500);
         cube.lightSequence(g, sizeof(g), 750);
         cube.lightSequence(h, sizeof(h), 500);
         cube.lightSequence(i, sizeof(i), 500);
         cube.lightSequence(j, sizeof(j), 500);
         cube.lightSequence(k, sizeof(k), 500);
         cube.lightSequence(l, sizeof(l), 500);
         cube.lightSequence(m, sizeof(m), 500);
         cube.lightSequence(n, sizeof(n), 500);
         cube.lightSequence(o, sizeof(o), 500);
         cube.lightSequence(p, sizeof(p), 500);
         cube.lightSequence(q, sizeof(q), 500);
         cube.lightSequence(r, sizeof(r), 500);
         cube.lightSequence(s, sizeof(s), 500);
         cube.lightSequence(t, sizeof(t), 500);
         cube.lightSequence(u, sizeof(u), 500);
         cube.lightSequence(v, sizeof(v), 500);
         cube.lightSequence(w, sizeof(w), 5000);
         cube.lightSequence(x, sizeof(x), 5000);
         cube.lightSequence(y, sizeof(y), 5000);
        cube.lightSequence(z, sizeof(z), 200);
       
        //for weeble wobble sequence
cube.lightSequence(aa, sizeof(aa), 5000);
     cube.lightSequence(bb, sizeof(bb), 500);
      cube.lightSequence(cc, sizeof(cc), 500);
       cube.lightSequence(dd, sizeof(dd), 500);
        cube.lightSequence(ff, sizeof(ff), 500);
         cube.lightSequence(gg, sizeof(gg), 500);
         cube.lightSequence(hh, sizeof(hh), 500);
         cube.lightSequence(ii, sizeof(ii), 500);
         cube.lightSequence(jj, sizeof(jj), 500);
         cube.lightSequence(kk, sizeof(kk), 500);
         cube.lightSequence(ll, sizeof(ll), 500);
         cube.lightSequence(mm, sizeof(mm), 500);
         cube.lightSequence(nn, sizeof(nn), 500);
         cube.lightSequence(oo, sizeof(oo), 500);
         cube.lightSequence(pp, sizeof(pp), 500);
         cube.lightSequence(qq, sizeof(qq), 500);
         cube.lightSequence(rr, sizeof(rr), 500);
         cube.lightSequence(ss, sizeof(ss), 500);
         cube.lightSequence(tt, sizeof(tt), 500);
         cube.lightSequence(uu, sizeof(uu), 500);
         cube.lightSequence(vv, sizeof(vv), 5000);
         cube.lightSequence(ww, sizeof(ww), 750);
         cube.lightSequence(xx, sizeof(xx), 1500);
         cube.lightSequence(yy, sizeof(yy), 500);
        
         //for helicopter
         cube.lightSequence(aaa, sizeof(aaa), 5000);
     cube.lightSequence(bbb, sizeof(bbb), 500);
      cube.lightSequence(ccc, sizeof(ccc), 500);
       cube.lightSequence(ddd, sizeof(ddd), 500);
       cube.lightSequence(eee, sizeof(eee), 500);
        cube.lightSequence(fff, sizeof(fff), 500);
         cube.lightSequence(ggg, sizeof(ggg), 500);
         cube.lightSequence(hhh, sizeof(hhh), 500);
         cube.lightSequence(iii, sizeof(iii), 500);
         cube.lightSequence(jjj, sizeof(jjj), 500);
         cube.lightSequence(kkk, sizeof(kkk), 500);
         cube.lightSequence(lll, sizeof(lll), 500);
         cube.lightSequence(mmm, sizeof(mmm), 500);
         cube.lightSequence(nnn, sizeof(nnn), 500);
         cube.lightSequence(ooo, sizeof(ooo), 500);
         cube.lightSequence(ppp, sizeof(ppp), 500);
         cube.lightSequence(qqq, sizeof(qqq), 500);
         cube.lightSequence(rrr, sizeof(rrr), 500);
         cube.lightSequence(sss, sizeof(sss), 500);
         cube.lightSequence(ttt, sizeof(ttt), 500);
         cube.lightSequence(uuu, sizeof(uuu), 500);
         cube.lightSequence(vvv, sizeof(vvv), 500);
         cube.lightSequence(www, sizeof(www), 500);
         cube.lightSequence(xxx, sizeof(xxx), 500);
         cube.lightSequence(yyy, sizeof(yyy), 500);
         cube.lightSequence(zzz, sizeof(zzz), 500);
}

Comments

lmonteiro4 (author)2014-06-24

gives me error here LedCube cube (3 levelPins, colPins);

what should I do

SwizzB (author)lmonteiro42014-08-05

you need to call for the led cube library so you should start your code with #include<LedCube.h>

sorry for my english :/

nerd7473 (author)2012-04-25

cool Is that an arduino uno? cause thats what im getting and I want to build a led cube

Cloudhail (author)nerd74732012-05-14

Yes it is an UNO! Good luck on your cube! Post some pics or a video of it when you are done.

nerd7473 (author)Cloudhail2012-05-14

Ok I think I might buy a kit instead of make my own because it would cost more to make one from scratch.

blac (author)nerd74732014-03-15

can get the parts from aliexpress.com much cheaper.

nerd7473 (author)blac2014-03-15

I think I will pass on the LED cube because I want to put my raspberry pi in a suitcase and use my uno for controlling RGB LEDs that will be behind the screen

Cloudhail (author)nerd74732012-05-14

True. I got all of my components from eBay in bulk and I have enough to last a few projects, and I want to get started on a 10x10x10, but if you want only the components to build a 3x3x3 then the kit is way cheaper. Also eBay has great deals on arduinos, I bought mine from RadioShack and regretted spending so much.

cheesecurd1899 (author)2013-10-28

I was wondering if you could take a look at my code.

ironheartbj18 (author)2013-05-20

amazing i learned something new today i adjusted pins with the code... i was using Arduino UNO using NPN transistors. its works well. its only 3x3x 2 for now take a look at the picture.

bullgog69er (author)2013-02-08

I built this cube but im very new to code and when i uploaded the code here it says " Led cube does not name a type" tring for hours to figure out cant can u help thanks

About This Instructable

8,814views

15favorites

License:

More by Cloudhail:Custom Animation for 3x3x3 led cube
Add instructable to: