Cube led Help ?

Hello,

I maked on a mini-project, which is a cube led (no RGB) 4 * 4 * 4 .For finish this project i bought:

  • Arduino Mega 2560
  • Max 7221
  • Capcitor 10 uf and 100nf
    resistors, etc. ....

To start I wired 8 LEDs to a max7221, but i have a problem ....
!

First I have the opportunity to use a library 'matrix' or 'ledcontrol' but I would know if this library are more optimized for my project ?

And for my cube i must use external supply and transistor but i don't see wiring ?

Secondly I could turn all the LEDs (8) simultaneously : ( is it a good solution or not ? )

#include <binary.h>
#include <LedControl.h>
#include <SPI.h>

LedControl lc=LedControl(12,11,10,1);
int timer = 1;

void setup() {
  
   lc.shutdown(0,false);
   lc.setIntensity(0,8);
   lc.clearDisplay(0); 
}
 
  
void loop () {


void setLed(int addr, int row, int col, boolean state);
while (1) {	
lc.setLed(0,0,1,true);   
delay(timer);
lc.setLed(0,0,1,false);  
lc.setLed(0,0,5,true); 
delay(timer);
lc.setLed(0,0,5,false);  
lc.setLed(0,0,2,true); 
delay(timer);
lc.setLed(0,0,2,false); 
lc.setLed(0,0,6,true);   
delay(timer);
lc.setLed(0,0,6,false);  
lc.setLed(0,0,3,true); 
delay(timer);
lc.setLed(0,0,3,false);  
lc.setLed(0,0,7,true); 
delay(timer);
lc.setLed(0,0,7,false); 
lc.setLed(0,0,4,true); 
delay(timer);
lc.setLed(0,0,4,false); 
lc.setLed(0,0,0,true); 
delay(timer);
lc.setLed(0,0,0,false); 

}

}

Secondly I would like make a scenario:

all LEDs high for 10 seconds
delay 2000ms
LED high 0,1,2,3 for 5 seconds
delay 2000ms
LED high 4,5,6,7

I started this code but I don't see how finish this code

#include <binary.h>
#include <LedControl.h>
#include <SPI.h>


int timer =150;
int temps;
LedControl lc=LedControl(12,11,10,1);



void setup() {
  
   lc.shutdown(0,false);
   lc.setIntensity(0,8);
   lc.clearDisplay(0); 
}
 
  
void loop () {


void setLed(int addr, int row, int col, boolean state);


if((millis() - temps) < 3000)
{	
lc.setLed(0,0,1,true);   
delay(timer);
lc.setLed(0,0,1,false);  
lc.setLed(0,0,5,true); 
delay(timer);
lc.setLed(0,0,5,false);  
lc.setLed(0,0,2,true); 
delay(timer);
lc.setLed(0,0,2,false); 
lc.setLed(0,0,6,true);   
delay(timer);
lc.setLed(0,0,6,false);  
lc.setLed(0,0,3,true); 
delay(timer);
lc.setLed(0,0,3,false);  
lc.setLed(0,0,7,true); 
delay(timer);
lc.setLed(0,0,7,false); 
lc.setLed(0,0,4,true); 
delay(timer);
lc.setLed(0,0,4,false); 
lc.setLed(0,0,0,true); 
delay(timer);
lc.setLed(0,0,0,false); 

}


}

thank you !

Hi victor56,

You might want to check out my cube on this link.

I used a max7219, which is almost exactly the same as max7221.

I did not use any library. I already knew how to use the max7219 chip without a library, and the libraries just seemed to get in the way and did not give any clear advantages for me.

All the patterns are performed by performing bit-manipulation on an array of 4 16-bit integers, one for each level.

You will probably not need a separate power supply for this project. Because of the multiplexing performed by the max7219, only 16 LEDs are switched on at any instant, even when all 64 appear to be on. 16 LEDs at 40mA = 640mA, but I have found it is no problem to run the cube from USB power.

You don't need any transistors, and only one resistor. The max7219 does not need them unless you are using more than 5V.

Paul

Because of the multiplexing performed by the max7219, only 16 LEDs are switched on at any instant,

8 actually - only one digit line at a time is take low to turn on 8 LEDs.

Thanks Bob, quite right.