Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: WonderTiger on Jan 21, 2013, 06:34 pm

Title: My 3x3x3 and 5x5x5 LED cube
Post by: WonderTiger on Jan 21, 2013, 06:34 pm
Hello,

My name is Mike and I'am currently living in the Netherlands. This year I started my first study: electrical engineering :).
So I went through some things what I could do to help me with my study and came out by the 3x3x3 LED cube.

Now I do understand almost everything and I should order my parts soon. This is my parts list:
-3 2N3904 NPN to use as ground switch (40V/200mA)
-3 22kOhms resistor for the NPN transistors.
-27 green LED's (2.2V/20mA)
-I calculated with this program: http://led.linear1.org/1led.wiz , that I needed 9*150ohms resistors. Though on the internet
I found that most people uses ~220Ohms resistors. I'm not sure why they do that, so if anyone can tell me I would be thankful :)!
-Perfboard, wires, etc
-Arduino Uno rev1.

Each transistor is connected to 1 of the 3 cathode levels. Then all the 3 transistors are soldered to 1 gnd wire (which then need to plugged in, into a GND port from the arduino).
Each transistor's base is connected to a digital pin from the arduino. When the cube is complete, it does look something like this: http://www.instructables.com/id/LED-Cube-and-Arduino-Lib/step3/Build-the-Circuit/

But I got a couple questions about what I can lit and what I can't:
-How many LED's can I lit up at the same time?
-Is it possible to lit LEDs on two different levels by grounding 2 or 3 levels at the same time and then let a current flow through a column? (So you can get a corner of 3 LEDs lit up the same time, without switching on high frequencies)
-Is it possible to turn on all 9 LEDS at the same time on 1 level?

Thanks in advance for helping a newbie ;).

Title: Re: 3x3x3 LED cube, newbie questions
Post by: Hippynerd on Jan 21, 2013, 07:02 pm
Technically, you could light up all the LEDs at one time, but that isnt how the software usually works. Usually you light up one led, or you light up the leds on a plane at one time, but that isnt true of all cubes. For your 3x3x3 cube, you will likely light up between 0 and 9 LEDs at a time. using up to 180mA at a time. each LED has a 33% duty cycle.

You probably want the 150 ohm resistors, but the only problem with using 220 ohm resistors is that they wont be as bright, so it will still work, and the LEDs will last longer at 220 ohms, but it may be insignificant. People using 220 ohm resistors maybe using LEDs with lower forward voltages, red are usually very low.


I think Its possible to do all the other things you list, but you probably wont want to do them.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 21, 2013, 08:04 pm
Ok then I will lower the value from the resistor  to around 180 ohm (to be in the middle of safe and bright ;)). So you are saying I can switch on all the grounds from each level (3 grounds in total) and then turn on 1 column so I get a vertical line that is lit. So I also can make a wall of LEDs just by turning on all the grounds and turning on 3 columns?

And I don't get your last sentence  :smiley-roll-blue: "I think Its possible to do all the other things you list, but you probably wont want to do them." Are you reffering to an easier way to make a 3x3x3 LED?
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Hippynerd on Jan 21, 2013, 08:14 pm
You could turn all 3 planes low, and turn one column high, lighting up all 3 LEDs, however, if you are resistored to drive your LEDs at 20mA, and you run 3 LEDs off one controller pin, you will be running 60mA on a device rated for 40, and will likely do damage to the microcontroller (if you run the leds at 10mA, you would be within spec.

You dont need to run the cube that way, the way you normally run a cube is by cycling through each layer, and lighting up just the LEDs in that layer that you want lit, then moving to the next layer. The LEDs appear to all be lit at the same time because of persistence of vision, but they are actually flashing on and off very quickly.

What i was referring to was the way you control the LEDs, there are many ways to do it, but will probably want to run things in loops things in sequence, but technically you dont have to do it that way.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: fungus on Jan 21, 2013, 08:42 pm

Each transistor is connected to 1 of the 3 cathode levels.


Cathode will work but normally you'd make each level an anode. This is because most LED drivers chips, etc. are designed to connect to LED cathodes.


-I calculated with this program: http://led.linear1.org/1led.wiz , that I needed 9*150ohms resistors. Though on the internet
I found that most people uses ~220Ohms resistors. I'm not sure why they do that, so if anyone can tell me I would be thankful smiley!


Because trying to run LEDs at exactly 20mA with resistors is a BAD IDEA.

There's about a million threads on the subject in these forums but here's the short version:
a) LED resistance isn't constant, it varies with voltage.
b) At the "20mA" point, the change in resistance is exponential, ie. a tiny error in voltage can produce a massive error in current.
c) Individual LEDs can easily vary by 10% so the error in (b) will happen, damaging the LED.

Solution, either:
i) Aim for 15mA (which won't be much dimmer), or
ii) Use a constant-current circuit (eg. LED driver chip)

The people who choose 220 Ohm resistors are going for the option (i), ie. run at 15mA.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 21, 2013, 08:57 pm
Thanks to you all! Then I will get resistor aimed @15mA. As well with the programming I will only lit up 1 layer at the time :)!

Control question:
If I want to lit up the whole cube, I need to do the following:
-Select layer 1 (turn off layer 2/3)
-Turn on all LED columns
-Turn off all LED columns
-Select layer 2 (turn off layer 1/3)
-Turn on all LED columns
-Turn off all LED columns
-Select layer 3 (turn off layer 1/2)
-Turn on all LED columns
-Turn off all LED columns

Or is this possible as well? (I'm newbie in programming as well ;)):
-Select layer 1 (turn off layer 2/3)
-Turn on all LED
-Turn off layer 1
-Select layer 2
-Turn off layer 2
-Select layer 3
-Turn off layer 3

I will post some pics of building this cube!
Title: Re: 3x3x3 LED cube, newbie questions
Post by: fungus on Jan 21, 2013, 09:17 pm

Control question:
If I want to lit up the whole cube, I need to do the following:
...
Or is this possible as well? (I'm newbie in programming as well ;)):
-Select layer 1 (turn off layer 2/3)
-Turn on all LED
-Turn off layer 1
-Select layer 2
-Turn off layer 2
-Select layer 3
-Turn off layer 3


That will work, yes... (for any pattern which is the same in all three layers)

Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 21, 2013, 09:21 pm
Ok thanks I will keep it in mind until I got everything soldered up!

Maybe someone want to check this for the last time, to be sure I buy the right stuff:

-Transistor+22kOhms resistor should be fine right? Datasheet transistor: http://www.produktinfo.conrad.com/datenblaetter/150000-174999/163350-da-01-en-Transistor_2N3904.pdf
-LED+220 ohms @15mA GREEN. Datasheet LED: http://www.produktinfo.conrad.com/datenblaetter/175000-199999/184705-da-01-en-WU_8_56_GD_LED_5mm_gruen.pdf

Thanks  :smiley-mr-green:
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Hippynerd on Jan 21, 2013, 10:15 pm
You are very close, but there is a critical step that is missing.


Starting with all pins low.
Turn plane 1 pin low
Turn column pin(s) high
  Wait some amount of time(1ms or more)
Turn column pins low
Turn plane pin high

Usually you set things back to a neutral position, unless you know that is what you want in the next step. Usually you turn the light on, wait, turn it off, move to the next step in the sequence.

Usually cubes run static patterns, but they can also be run by calculations (like with the game of life, or random.)
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 21, 2013, 10:22 pm
Ye I did forget the delay :|.

Though for me its more like this, right?:
Starting with all pins low.
Turn plane 1 pin high
Turn column pin(s) high
  Wait some amount of time(1ms or more)
Turn column pins low
Turn plane pin low

I use npn transistors that will switch to ground when current is provided to the base pin from the transistor, this is why I need to set plane 1 to a value HIGH instead of low, right?
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Hippynerd on Jan 21, 2013, 11:41 pm
Yes, you send high from the microcontroller to the NPN to turn the plane low.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 21, 2013, 11:55 pm
Ok thanks! Then If you can confirm the 22kOhm will be sufficient for the 2N3904 transistor: http://www.produktinfo.conrad.com/datenblaetter/150000-174999/163350-da-01-en-Transistor_2N3904.pdf. Then I will be ready to place my order ;).
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Hippynerd on Jan 22, 2013, 12:12 am
Im probably not the best person to ask about what transistor to use. Im actually considering using tiny logic level mosfets instead of BJT type transistors for something that only needs a quarter amp. One of the features of using an n channel mosfet is no resistor required.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 22, 2013, 01:03 am
No problem, you helped me out alot on other stuff though. Thanks again!!!

I'll guess somebody else can take a look at it :).
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 22, 2013, 10:33 pm
Is it possible for somebody to explain me why I need to use a resistor on the base from the transistor? I did alot of reading about why a resistor is needed on the base from the transistor (as NPN switch), but I keep seeing different answer on different forums this makes me understand it less and less. So if someone briefly can explain why a resistor is needed on the base (and how you calculate it) I would be very happy with it :)!

sorry for the newbie questions, still in the learning process  :)
Title: Re: 3x3x3 LED cube, newbie questions
Post by: michinyon on Jan 23, 2013, 04:27 pm
The resistor limits the current which might go in and out of whatever is driving the base of the transistor,
such as an arduino pin.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: retrolefty on Jan 23, 2013, 05:19 pm

Is it possible for somebody to explain me why I need to use a resistor on the base from the transistor? I did alot of reading about why a resistor is needed on the base from the transistor (as NPN switch), but I keep seeing different answer on different forums this makes me understand it less and less. So if someone briefly can explain why a resistor is needed on the base (and how you calculate it) I would be very happy with it :)!

sorry for the newbie questions, still in the learning process  :)


It's because once the voltage applied across the emitter/base junction of a transistor is higher then the forward voltage drop rating for that base/emitter junction it will fully turn on and act like a short circuit drawing current well in excess of it's maximum base current limit (and the maximum output current being drawn from say an arduino output pin when set high that one might wire to the base terminal), so something in the base circuit needs to limit the base current to at or below it's maximum rated current value, and a resistor wired in series with the base terminal just happens to be the simplest way to do that.

Lefty
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 24, 2013, 12:53 am
Thanks for the explanations, now I understand why I needed it.

I got another question about the 13th pin from arduino. According to arduino pin 13th has an built in resistor so I can directly put a LED to pin 13 and ground. When I connect a column on pin 13 does the LEDs shine less bright because there is an extra resistor built in on pin 13(my 220ohm resistor + arduino uno pin 13th resistor?)
Title: Re: 3x3x3 LED cube, newbie questions
Post by: retrolefty on Jan 24, 2013, 02:51 am

Thanks for the explanations, now I understand why I needed it.

I got another question about the 13th pin from arduino. According to arduino pin 13th has an built in resistor so I can directly put a LED to pin 13 and ground. When I connect a column on pin 13 does the LEDs shine less bright because there is an extra resistor built in on pin 13(my 220ohm resistor + arduino uno pin 13th resistor?)


There is a series resistor/led wired to pin 13 mounted on most arduino boards. However the shield pin 13 is wired directly to the AVR pin so the pin is not protected by the on board resistor, so all the same current rules apply to using pin 13 as with any other AVR I/O pin.

Lefty
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 24, 2013, 09:36 pm
All the components are send today! Soon I will start building the cube :smiley-mr-green:.

A little programming question. What will happen when I don't use a delay between switching on and off the LED. I would guess it wouldnt turn on the LED because it's been turned on and off too fast. Will I do damage on any components if I don't use delay.

And it's true the arduino pin can take up to 200mA? So I will be able to put on 9 LEDs on 1 plane ( 9 * ~15mA= 135mA). Thanks for the help again :smiley-roll-blue:.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 26, 2013, 12:32 pm
Got my LED cube build today :D! This code I made as a test:

I used for() loops as delay between the columns as well for making the led columns run at their full brightness.

Code: [Select]

int layer1 = 11;
int layer2 = 12;
int layer3 = 13;
int led1   = 10;
int led2   = 9;
int led3   = 8;
int led4   = 7;
int led5   = 6;
int led6   = 5;
int led7   = 4;
int led8   = 3;
int led9   = 2;
int r      = 1;




void setup()
{
  pinMode(layer1, OUTPUT);
  pinMode(layer2, OUTPUT);   
  pinMode(layer3, OUTPUT); 
  pinMode(led1,   OUTPUT);
  pinMode(led2,   OUTPUT); 
  pinMode(led3,   OUTPUT); 
  pinMode(led4,   OUTPUT); 
  pinMode(led5,   OUTPUT); 
  pinMode(led6,   OUTPUT); 
  pinMode(led7,   OUTPUT); 
  pinMode(led8,   OUTPUT); 
  pinMode(led9,   OUTPUT); 
 

}

void loop()
{
while(r<=5){
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, LOW);
  digitalWrite (led5, HIGH);
 
for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led1, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led1, LOW);
}

for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led2, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led2, LOW);
}

for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led3, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led3, LOW);
}

for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led6, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led6, LOW);
}

for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led9, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led9, LOW);
}

for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led8, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led8, LOW);
}

for(int i = 0; i <= 15;i++){
  digitalWrite (layer1,  HIGH);
  digitalWrite (led7,    HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led7, LOW);
}
for(int i = 0; i <= 15;i++){
  digitalWrite (layer1, HIGH);
  digitalWrite (led4, HIGH);
  delay(1);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(1);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(1);
  digitalWrite (layer3, LOW);
  digitalWrite (led4, LOW);
}
digitalWrite (led5, LOW);
digitalWrite (layer1, LOW);
digitalWrite (layer2, LOW);
digitalWrite (layer3, LOW); // RESET all layers to OFF
r = r++;                     
}
r = 1;                       
while (r<=10){
  digitalWrite (layer1, HIGH);
  digitalWrite (led1, HIGH);
  digitalWrite (led3, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led9, HIGH);
  delay(75);
  digitalWrite (layer1, LOW);
  digitalWrite (layer2, HIGH);
  delay(75);
  digitalWrite (layer2, LOW);
  digitalWrite (layer3, HIGH);
  delay(75);
  digitalWrite (led1, LOW);
  digitalWrite (led3, LOW);
  digitalWrite (led7, LOW);
  digitalWrite (led9, LOW);
  delay(75);
  digitalWrite (led2, HIGH);
  digitalWrite (led4, HIGH);
  digitalWrite (led6, HIGH);
  digitalWrite (led8, HIGH);
  delay(75);
  digitalWrite (layer3, LOW);
  digitalWrite (layer2, HIGH);
  delay(75);
  digitalWrite (layer2, LOW);
  digitalWrite (layer1, HIGH);
  delay(75);
  digitalWrite (led2, LOW);
  digitalWrite (led4, LOW);
  digitalWrite (led6, LOW);
  digitalWrite (led8, LOW);
  r = r++;
}
r=1;
}


Here a video :): http://www.youtube.com/watch?v=4nfarTktGv8
If anyone has some tips what I could do better on my code, feel free to let me know :).
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Hippynerd on Jan 26, 2013, 06:18 pm
Yay, working cube!
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Jan 31, 2013, 12:17 am
Another video :), multiplexed so only 1 layer is lit on any given time(im using array's and for loops to turn on the LEDs, easier to program/the code is shorter):
http://www.youtube.com/watch?v=n4JEfAUBjKc

edit:
this code has even less lines as the one that I showed 2 posts back :).
Title: Re: 3x3x3 LED cube, newbie questions
Post by: vtterp on Jan 31, 2013, 11:03 am
Neat! Nice work. Would you mind posting the new code as a reference?  Definitely think it would be helpful for me as jump into the programming of my cube.  Thanks.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Arduino001 on Feb 01, 2013, 04:27 pm
Yep no problem(this code is a little different than showed in the video):

Code: [Select]

/* 3x3x3 LED cube
* ------------
* Created January 2013
* http://arduino.cc/forum/index.php/topic,144057.0.html
* Made by M.Neuhaus
*/

int lvlPins[3] = {11,12,13};
int ledPins[9] = {10,9,8,7,6,5,4,3,2};
int repeat_value = 0;
int speed_value;    //Used in a double while loop
int randomledPins;
int randomlvlPins;

void setup()
{
  for(int i=0; i<3; i++){
    pinMode(lvlPins[i], OUTPUT);
  }
  for(int i=0; i<9; i++){
    pinMode(ledPins[i], OUTPUT);
  }
}
void loop(){
  repeat_value = 0;
  speed_value = 50;
  while(speed_value > 1){ 
    while(repeat_value < speed_value){
        for(int i=0; i<3; i++){digitalWrite(ledPins[i], HIGH);}
        for(int i=0; i<3; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
        for(int i=0; i<3; i++){digitalWrite(ledPins[i], LOW);}
        repeat_value+=1;  //wall 0,1,2
    }                                                                                         
    repeat_value = 0;       
    while(repeat_value < speed_value){
        for(int i=0; i<3; i++){digitalWrite(ledPins[i+2+i*2], HIGH);}
        for(int i=0; i<3; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
        for(int i=0; i<3; i++){digitalWrite(ledPins[i+2+i*2], LOW);}
        repeat_value+=1;  //wall 2,5,8
    } 
    repeat_value = 0; 
    while(repeat_value < speed_value){
        for(int i=0; i<3; i++){digitalWrite(ledPins[i+6], HIGH);}
        for(int i=0; i<3; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
        for(int i=0; i<3; i++){digitalWrite(ledPins[i+6], LOW);}
        repeat_value+=1;  //wall 6,7,8
    } 
    repeat_value = 0; 
    while(repeat_value < speed_value){
        for(int i=0; i<3; i++){digitalWrite(ledPins[i+i*2], HIGH);}
        for(int i=0; i<3; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
        for(int i=0; i<3; i++){digitalWrite(ledPins[i+i*2], LOW);}
        repeat_value+=1;  //wall 0,3,6
    }     
    repeat_value = 0;
    speed_value-=5;       //acceleration
  }       
  while(repeat_value<200){
    digitalWrite(lvlPins[0], HIGH);
    digitalWrite(ledPins[4], HIGH);
    delay(1);
    digitalWrite(lvlPins[0], LOW);
    digitalWrite(lvlPins[1], HIGH);
    for(int i=0; i<3; i++){digitalWrite(ledPins[i+3], HIGH); digitalWrite(ledPins[1], HIGH); digitalWrite(ledPins[7], HIGH);}
    delay(1);
    digitalWrite(lvlPins[1], LOW);
    for(int i=0; i<3; i++){digitalWrite(ledPins[i+3], LOW); digitalWrite(ledPins[1], LOW); digitalWrite(ledPins[7], LOW);}
    digitalWrite(lvlPins[2], HIGH);
    digitalWrite(ledPins[4], HIGH);
    delay(1);
    digitalWrite(lvlPins[2], LOW);
    digitalWrite(ledPins[4], LOW);
    repeat_value+=1;      //Orb
  }
  repeat_value=0;
  while(repeat_value<500){
    for(int i=0; i<5; i++){digitalWrite(ledPins[i+i], HIGH);}
    for(int i=0; i<1; i++){digitalWrite(lvlPins[i+1], HIGH); delay(1); digitalWrite(lvlPins[i+1], LOW);}
    repeat_value+=1;   //Orb expands to 4 corners of cube
  }
  repeat_value = 0;
  while(repeat_value<400){
    for(int i=0; i<5; i++){digitalWrite(ledPins[i+i], HIGH);}
    for(int i=0; i<3; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
    for(int i=0; i<5; i++){digitalWrite(ledPins[i+i], LOW);}
    if(repeat_value>200){
      for(int i=0; i<4; i++){digitalWrite(ledPins[2*i+1], HIGH);}  //Led 1,3,5,7 ON
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
      if(repeat_value>250){
        for(int i=0; i<1; i++){digitalWrite(lvlPins[i+1], HIGH); delay(1); digitalWrite(lvlPins[i+1], LOW);}
      }
      if(repeat_value>300){
        for(int i=0; i<1; i++){digitalWrite(lvlPins[i+2], HIGH); delay(1); digitalWrite(lvlPins[i+2], LOW);}
      }
      for(int i=0; i<4; i++){digitalWrite(ledPins[2*i+1], LOW);}
    }           
    repeat_value+=1;
  }
  repeat_value=0;
  for(int i=0; i<9; i++){digitalWrite(ledPins[i], HIGH);}
  while(repeat_value<200){
    for(int i=0; i<2; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);} 
    repeat_value+=1;   // Only layer 1, 2 ON
  }
  repeat_value=0;
  while(repeat_value<150){
    for(int i=0; i<1; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);} 
    repeat_value+=1;   //Only layer 1 ON
  }
  for(int i=0; i<9; i++){digitalWrite(ledPins[i], LOW);}
  repeat_value=0;
  while(repeat_value<60){
    randomledPins=random(9);
    randomlvlPins=random(3);
    digitalWrite(ledPins[randomledPins], HIGH);
    digitalWrite(lvlPins[randomlvlPins], HIGH);
    delay(50);
    digitalWrite(ledPins[randomledPins], LOW);
    digitalWrite(lvlPins[randomlvlPins], LOW);
    repeat_value+=1;
  }
  repeat_value = 0;
  speed_value = 0; 
  while(repeat_value<5){
    while(speed_value<30){    //Use of 'speed_value' due double while loop
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+1], HIGH);}
      for(int i=0; i<3; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+1], LOW);}
      speed_value+=1;
    }
    speed_value = 0;
    while(speed_value<30){
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+2], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i+2], HIGH); delay(1); digitalWrite(lvlPins[i+2], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+2], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+1], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i+1], HIGH); delay(1); digitalWrite(lvlPins[i+1], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+1], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i], LOW);}
      speed_value+=1;
    }
    speed_value = 0;
    while(speed_value<90){
      for(int i=0; i<9; i++){digitalWrite(ledPins[i], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i+1], HIGH); delay(1); digitalWrite(lvlPins[i+1], LOW);}
      for(int i=0; i<9; i++){digitalWrite(ledPins[i], LOW);}
      speed_value+=1;
    }
    speed_value = 0;
    while(speed_value<30){
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i+2], HIGH); delay(1); digitalWrite(lvlPins[i+2], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+1], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i+1], HIGH); delay(1); digitalWrite(lvlPins[i+1], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+1], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+2], HIGH);}
      for(int i=0; i<1; i++){digitalWrite(lvlPins[i], HIGH); delay(1); digitalWrite(lvlPins[i], LOW);}
      for(int i=0; i<3; i++){digitalWrite(ledPins[3*i+2], LOW);}
      speed_value+=1;
    }
  repeat_value+=1;
  speed_value = 0;
  }

Title: Re: 3x3x3 LED cube, newbie questions
Post by: Pedro147 on Feb 02, 2013, 02:48 am
Thanks for sharing that code Arduino001 ... I like your work, well done  8) It always amazes me that you people that classify themselves as Newbies come up with such great code....   I collect any 3 x 3 cube code that I find because it helps me to learn about how to code, so yours will certainly be going into my collection. In case you're interested here is one I did and also a link to some excellent code that uses PROGMEM

http://www.instructables.com/id/The-Arduino-LED-Cube/step5/Programming-Time/

Code: [Select]
/* Code by Pedro147 inspired by this -

http://www.abrushfx.com/Arduino/ledcube3.html

*/

int ledRow[] = { 11, 12, 13 };
int ledCol[]= {  2, 3, 4, 5, 6, 7, 8, 9, 10 };
int timer= 10;




void setup()
{  
 for( int i =  0; i < 3; i++)

 {
   pinMode( ledRow[i],OUTPUT);
 }

 {  
   for(int j =  0; j < 9; j++)

   {
     pinMode( ledCol[j],OUTPUT);
   }
 }
}


void onLED(int ledRow, int ledCol){

 digitalWrite(ledRow, HIGH);
 digitalWrite(ledCol, HIGH);

}


void offLED(int ledRow, int ledCol)
{
 digitalWrite(ledRow, LOW);
 digitalWrite(ledCol, LOW);
}


void allOff()
{
 for(int i = 3; i--;)
 {
   for(int j = 9; j--;)
   {
     offLED(ledRow[i],ledCol[j]);
   }
 }
}


void oneToNine_ColsOn()
{
 for(int j = 9; j--;)

 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}


void everySecond_ColsOn1()
{

 for(int j = 0; j< 9; j+=2)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}


void everySecond_ColsOn_2()
{

 for(int j = 1; j< 9; j+=2)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}
void lhWall_fToR()

{

 for(int j = 0; j< 9; j+=3)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}

void rhWall_fToR()

{

 for(int j = 2; j< 9; j+=3)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}


void frontWall_LtoR()
{
 for(int j = 0; j< 3; j++)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}

void rearWall_LtoR()
{
 for(int j = 6; j<9; j++)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(10);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}


void centreWall_LtoR()
{
 for(int j = 3; j<6; j++)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(timer);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}

void centreWall_fToR()

{

 for(int j = 1; j< 9; j+=3)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(timer);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}

void diagWall_LtoR()
{
 for(int j = 0; j < 9; j+=4)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(timer);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}

void diagWall_RtoL()
{
 for(int j = 2; j < 8; j+=2)
 {
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(timer);
     digitalWrite(ledCol[j], HIGH);
   }
 }
}

void rowPaneFigure8()
{
 for (int i = 0; i < 3; i++)

 {
   for(int j = 0; j < 3; j++)   // light LED's 1 - 3 on/off on top level

   {
     onLED(ledRow[i],ledCol[j]);         // 7 8 9
     delay(timer);                       // 4 5 6
     offLED(ledRow[i],ledCol[j]);        // 1 2 3
   }
   for(int j = 5; j > 2; j--)  // light LED's 6 - 4 on/off on top level
   {
     onLED(ledRow[i],ledCol[j]);
     delay(timer);
     offLED(ledRow[i],ledCol[j]);
   }
   for(int j = 6; j < 9; j++)  // light LED's 7 - 9 on/off on top level
   {
     onLED(ledRow[i],ledCol[j]);
     delay(timer);
     offLED(ledRow[i],ledCol[j]);
   }
   for(int j = 5; j > 2; j--)   // light LED's 6 - 4 on/off on top level
   {
     onLED(ledRow[i],ledCol[j]);
     delay(timer);
     offLED(ledRow[i],ledCol[j]);
   }

 }

}

void frontTorear_flash1()
{
 for(int j = 0; j < 9; j+=3)
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(20);
     digitalWrite(ledCol[j], HIGH);
   }
}


void frontTorear_flash2()
{
 for(int j = 1; j < 9; j+=3)
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(20);
     digitalWrite(ledCol[j], HIGH);
   }
}


void frontTorear_flash3()
{
 for(int j = 2; j < 9; j+=3)
   for(int i = 3; i--;)
   {
     digitalWrite(ledRow[i], HIGH);
     delay(20);
     digitalWrite(ledCol[j], HIGH);
   }
}

void randomColumnsOnOff()
{
 int colmax = 9;
 int stCol  = random(0,colmax);

 {
   digitalWrite(ledRow[0], HIGH);
   digitalWrite(ledCol[stCol], HIGH);
   digitalWrite(ledRow[1], HIGH);
   digitalWrite(ledCol[stCol], HIGH);
   digitalWrite(ledRow[2], HIGH);
   digitalWrite(ledCol[stCol], HIGH);
   delay(timer);
   allOff();



 }
}
void loop()
{
 oneToNine_ColsOn();
 delay(10);
 allOff();
 delay(10);
 everySecond_ColsOn1();
 delay(10);
 allOff();
 delay(10);
 everySecond_ColsOn_2();
 delay(10);

 oneToNine_ColsOn();
 delay(10);
 allOff();
 delay(10);
 everySecond_ColsOn1();
 delay(10);
 allOff();
 delay(10);
 everySecond_ColsOn_2();
 delay(10);


 lhWall_fToR();
 delay(100);
 allOff();
 centreWall_fToR();
 delay(100);
 allOff();
 rhWall_fToR();
 delay(100);
 allOff();

 frontWall_LtoR();
 delay(100);
 allOff();
 centreWall_LtoR();
 delay(100);
 allOff();
 rearWall_LtoR();
 delay(100);
 allOff();

 rowPaneFigure8();

 centreWall_LtoR();
 allOff();
 diagWall_LtoR();
 allOff();
 centreWall_fToR();
 allOff();
 diagWall_RtoL();
 allOff();
 frontTorear_flash1();
 delay (timer);
 allOff();
 frontTorear_flash2();
 delay (timer);
 allOff();
 frontTorear_flash3();
 delay (timer);
 allOff();
 randomColumnsOnOff();
 randomColumnsOnOff();
 randomColumnsOnOff();
}

Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Feb 02, 2013, 06:04 pm
Don't know how, but Arduino001 should be me (WonderTiger),  Weird..... Thanks anyway for your positive reply :D! (and thanks ofcourse for sharing your code as well ;))
Title: Re: 3x3x3 LED cube, newbie questions
Post by: mbanzi on Feb 02, 2013, 06:18 pm
WonderTiger today the cache has been playing some bad pranks to a few people.
monday we'll have a look at it and fix it.

m
Title: Re: 3x3x3 LED cube, newbie questions
Post by: Pedro147 on Feb 02, 2013, 08:17 pm
My apologies WonderTiger. I just looked at the name of the person that posted the code without realising that this was not the OP... opps  :smiley-mr-green:

p.s - that damn cache is responsible for a lot of misunderstandings on the web
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Feb 03, 2013, 10:51 am
No problem, I just thought it was weird because I was sure I made the post  :smiley-mr-green:. Anyway, my next project will be 5x5x5. I already ordered some shift register to experiment with and learn the basics of them :), I probably going to use shift registers on my 3x3x3 cube first to make sure I understand the programming and the way the shift registers work.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Feb 04, 2013, 10:12 pm
I have a question about the current draw from the arduino 5v pin. Is it true that i can pull around 450mA from that pin(Usb powered, arduino uno itself use around 50mA or something close to that, so that leaves me 450mA IF all the digital pins are turned low).

Thanks in advance :)!
Title: Re: 3x3x3 LED cube, newbie questions
Post by: fungus on Feb 05, 2013, 09:28 am

I have a question about the current draw from the arduino 5v pin. Is it true that i can pull around 450mA from that pin(Usb powered, arduino uno itself use around 50mA or something close to that, so that leaves me 450mA IF all the digital pins are turned low).

Thanks in advance :)!


On USB power, yes. You can do about 20 LEDs at 20mA, powered from the 5V pin (not from Arduino I/O pins).

For more than that you need another 5V power supply.
Title: Re: 3x3x3 LED cube, newbie questions
Post by: WonderTiger on Feb 05, 2013, 11:07 am
Ok thanks:D! I only will use around 325 mA at the most so arduino will provide enough when connected to USB, thanks again!
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 11, 2013, 09:49 pm
So after 3 days I finished my 5x5x5 LED cube. Now everything is working fine, however if I multiplex more then three layers my LEDs goes less bright then when I'm only multiplexing 3 layers. It's not a big deal but if someone has an explanation for it it would be great!

pics comming soon!
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Hippynerd on Feb 13, 2013, 07:48 pm
How has this been going? do you have pix or video yet?

I dont understand your statement about how its going not so bright, or why that might be happening.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 17, 2013, 10:14 pm
Sorry for the delay but I have been on vacation lately. Tommorow I will post some pics of it. I still have some struggling with the code but I almost figured out. So the videos will be posted within a week :).

I figured out the brightness issue though. Its because the duty cycle is around 1/5 if I multiplex 5 layers. To fix it I should pulse my leds with much more current then I do right now. I dont really mind about the brightness loss so I keep it in its original state:).
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: CrossRoads on Feb 17, 2013, 11:49 pm
25 LEDs at 20mA is 500mA; you can't go much brighter without another supply.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: RosDaddy on Feb 18, 2013, 03:32 pm
Hi. im an arduino newbie as well and I just built a 3x3x3 led cube this weekend and wanted to ask you a couple of questions. I built the cube and made sure all the pins worked but got a little bit stumped when it came to programming since it was my first time. Just from reading through these posts I understand now that it is smarter to light up each layer at a time so I have a 1/3 duty cycle. (I was doing 1 led at a time with 1/27th duty cycle. :*) But my first question is why use transistors? I hooked each layer up to a specific pin and when I want the layer off I just set the pin to HIGH. Is there an advantage to using transistors?

My next questions is going to be about how you simplified your code. But im going to rewrite my coding a little tonight just so I can see the cube in action and then I will post it.

Thanks in advance! and good work, I hope I will learn as fast as you did!
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: fillbob1 on Feb 18, 2013, 03:42 pm
What I did was do the 1/27 duty cycle, alot of code but you can copy and paste so it becomes easier. You could also use for less code is lable a xyz not sure how to do that though.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: retrolefty on Feb 18, 2013, 03:45 pm
Quote
But my first question is why use transistors? I hooked each layer up to a specific pin and when I want the layer off I just set the pin to HIGH. Is there an advantage to using transistors?


Not just an advantage, but a requirement to use a transistor to enable or disable each layer. As when a layer is enable the amount of current allowed to flow is dependent on the number of leds your software has commanded to be on for that layer and that can vary from 0 to 9 leds for a 3x3x3 cube.

So worst case, 9 leds x 20ma= 180ma is way more current then the arduino output pin controlling the layer can handle, so the need for the arduino output pin to control a switching transistor that can handle that amount of current.

That make sense?

Lefty
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 18, 2013, 04:15 pm
Here are some pics :):

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138540-20130218-130309.jpg)

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138541-20130218-130332.jpg)

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138552-20130218-130859.jpg)

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138542-20130218-130648.jpg)

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138553-20130218-130916.jpg)

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138554-20130218-131104.jpg)

(http://www.modelbouwforum.nl/forums/members/wondertiger-albums-5x5x5-led-cube-%2Aproject%2A-picture138555-20130218-131112.jpg)

Next time I'm gonna design a PCB and etch it at school.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Hippynerd on Feb 18, 2013, 06:03 pm
Somehow this ended up a lot more parts than I had originally expected. it looks like you are using 5 transistors for switching planes on or off, and 5 shift registers for columns.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 18, 2013, 06:57 pm
Yes there quite a few parts in this one, here a list of all things I used:

-125 LEDs
-Copper wire to give the layers more thoughness
-5 NPN 800mA (2n2222) transistors
-5 x 150 ohm resistor for the transistors
-2 experiment boards to solder the components on
-14 male, 5pin connectors
-13 female, 5 pin connectors
-1 male, 3 pin connector
-2 meter 10wires ribbon cable
-6 meter white wire
-2 meter black wire
-2 meter red wire
-1 meter blue wire
-2 meter green wire
-2 meter yellow wire
-6 shift registers and 6 ic-sockets
-6 100nF ceramic capacitors
-25x 220 ohm resistors
-1x 10K resistor

This is all I used. I use 5 shift registers to control 5 LEDs per shift register, the 6th shift registers is for controlling the layers via the NPN transistors.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: RosDaddy on Feb 18, 2013, 07:33 pm
5x5x5 cube looks good!

I still dont understand the need for transistors for the grounds. When I want to ground a layer I just send a LOW signal to that layer. When I want to turn the layer off I send a HIGH to the layer. A 5V HIGH shouldn't be enough voltage to reverse bias the led so it shouldn't hurt it.

I may be wrong :smiley-eek:

Thanks!
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 18, 2013, 07:47 pm
The digital pins from the arduino can only sink(/source) up, up to 40mA. If I turn on 25 LEDs on one layer the total current that need to be sinked by the digital pin would be 25*13mA = 325mA, this is far too much for a digitalpin. Instead I use NPN transistors, the collector from the transistor is connected to each layer of the cube. The emitter is connected to ground from the arduino (Ground from the arduino can sink up to around 450 mA on USB) and the base is connected to a digital pin on the arduino (in my case to the shift register). Now I am able to turn on 25 LEDs on one layer without frying something. The other advantage from transistors is the way how the ground is turned on/off, I send a HIGH signal to the base from the transistor so it switches the selected layer to ground. Because I can use HIGH instead of LOW (what you mentioned) it makes it easier to program.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: CrossRoads on Feb 18, 2013, 11:11 pm
Nice job with the build and assembly Wondertiger.
What current are you seeing from the 74HC595 outputs?
Set an LED high and measure the voltage across a 220 resistor.
I'd expect something like 2.8V/220 = 12.7ma if your LEDs have a Vf of 2.2V and you're actually gettiing 5V out of the 74CH595.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 18, 2013, 11:37 pm
I did a measurement with a cheap digital volt meter and it came around 2.5V. I think I should invest in a better multimeter in the first place (a buddy of mine has an industrial fluke that works really well he said, maybe I should look for something like that) to get some accurate readings  :smiley-red:
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: retrolefty on Feb 18, 2013, 11:46 pm

I did a measurement with a cheap digital volt meter and it came around 2.5V. I think I should invest in a better multimeter in the first place (a buddy of mine has an industrial fluke that works really well he said, maybe I should look for something like that) to get some accurate readings  :smiley-red:


There are many reasons one might want to upgrade to say a fluke DMM (I own 3) but for the kind of stuff your doing with a typical arduino project a simple cheap DMM (unless defective) will not be a big deal as far as accuracy goes. Like any tool, it's not so much the tool but rather knowing how to use it properly and understanding it's limitations. The biggest draw back of modern DMM is that it always displays a number even when the number being displayed doesn't mean what you might expect it to or want it to mean. Measuring the output of a active PWM pin is one example of a improper measurement for a DMM, it will display a number but it doesn't mean what you think it means.

Lefty
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Feb 18, 2013, 11:55 pm
I absolutely agree with the statement you made. However I think a good meter will be a good investment though (for my study and other projects in the future) even if it isnt really meaningful for now yet.

Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: CrossRoads on Feb 19, 2013, 12:00 am
I use an inexpensive Extech (extech 330) meter that seems to work really well. You don't need to go overboard with an expensive Fluke meter.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: retrolefty on Feb 19, 2013, 12:03 am

You're absolutely right with the statement you made. However I think a good meter will be a good investment though(for my study and other projects in the near future) even if it isnt really meaningful for these kinds of projects yet.




I agree mostly about good test equipment being a near lifetime investment that will pay good dividends for a long long time. After working for decades in the electronics industry I found that fluke meters and tektronix scopes were all I ever wanted to own for personal use.

But the point is that arduino beginners should be encouraged that their first purchase to make after their arduino board is a DMM, well before obtaining any other components and/or modules for their various projects. So the $10 DMMs serve a good purpose in at least getting them started on the right path. Many young people starting out just can't yet afford the investment costs of say a Fluke meter, but can swing for a $10 DMM which is much better then no DMM at all which all too many appear to have.

Lefty
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: CrossRoads on Feb 19, 2013, 12:06 am
We just got my son a $19 extech meter, sprung for a little extra because this one also came with a thermocouple probe.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: retrolefty on Feb 19, 2013, 12:10 am

We just got my son a $19 extech meter, sprung for a little extra because this one also came with a thermocouple probe.


Cool, and if he misbehaves tell him you will use that probe to take his temperature the 'old fashion way'.  ;)

Lefty

Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: CrossRoads on Feb 19, 2013, 12:31 am
We got him a $119 Weller soldering station too, so I think he'll behave.  Off to college in the fall...
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: retrolefty on Feb 19, 2013, 12:42 am

We got him a $119 Weller soldering station too, so I think he'll behave.  Off to college in the fall...


What, no pocket protector? What will the other nerds think of him?

Lefty
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: CrossRoads on Feb 19, 2013, 02:09 am
Going to RPI, whole schoolful of engineers. Kids are too cool for pocket protectors these days.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Mar 07, 2013, 11:17 pm
Been a while I posted something here. Last weeks I was very busy with school (we are developing a weighing scale). However I managed to make a very easy animation for my cube :), enjoy:

http://www.youtube.com/watch?v=9A1HSdPkN8A

Edit: see my universal library: http://forum.arduino.cc/index.php?topic=336469.0 (http://forum.arduino.cc/index.php?topic=336469.0)
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Un4Seen on Mar 08, 2013, 10:13 am
Hey Mike!

Nice video :)

I've recently built a similar 4x4x4 cube. I'm having some trouble with ghosting on the cube (it seems that the cathodes are not turning off quickly enough). The way it manifests is that when I turn on a pair of a new anode plane and a new cathode column, the LED which at the intersection of the new plane and the old column, lights up for a brief moment. This results in ghosting. It is most likely a hardware problem, but I want to make sure that it's not a software problem. Have you had any kind of similar ghosting problem? Would it be possible for me to see your code, maybe I'll get some insights about what I might be doing wrong...

Thanks,
Andras
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Mar 08, 2013, 02:42 pm
I have not seen 'ghosting'on my cube. However if I light up 1 layer, the layer above the lit one will shine very dim. But this is due the light goes through the bottom of the LEDs.

Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Un4Seen on Mar 08, 2013, 02:46 pm
Yes, I have the shine-through effect too, but that's not a big problem and there's not much you can do about it anyway. Thank you for the code! :) I will check it.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Mar 08, 2013, 02:51 pm
this is the proper link in case its not working ;):
https://www.dropbox.com/sh/5jzjoelre7b6h4g/t-_ULpv3Oq/DesignV1.ino

Edit: Notice in this code all the animationDelay times are 100milliseconds. In the video I showed they aren't.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Un4Seen on Mar 08, 2013, 03:04 pm
I have noticed that you use shiftOut() instead of the SPI library that I use. Theoretically the SPI library's methods are faster, but I'll try out shiftOut() too, who knows, maybe it makes a difference...
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Mar 08, 2013, 03:47 pm
Yes SPI transfer is faster, however this code is version 1, so I will have a look at it to let it perform better in the near future :).

Maybe I'm going to create an array generator for the animations as well.
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Mar 08, 2013, 04:01 pm
Well I couldnt wait and modified the code to SPI.transfer. Still no problems with ghosting...

link:

https://www.dropbox.com/sh/5jzjoelre7b6h4g/xAy4sVeAhI/LED_CUBE.ino

Edit: Still the code I'm using is not a good way to program the cube. After a while u will run out of memory and the cube is going to do strange things. Even now I'm using PROGMEM its not working. Is it possible that you can post your code as well??
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Hippynerd on Mar 08, 2013, 07:05 pm
I have built a few cubes, and I dont think that I have noticed any ghosting. Do you have any videos of the ghosting?
My first cube only lit on LED at a time, I modified it to use shift registers and it lights 16 LEDs at a time. I havnt noticed any ghosting, but maybe its happening, and I just didnt notice?
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: Un4Seen on Mar 08, 2013, 08:59 pm
Hi Guys!

@Hippynerd: If your cube would have ghosting like mine, you would notice it, trust me :) It is very visible and... annoying. Unfortunately I can't create a video as my camera is broken and even for my last video I had to borrow one (I really should get one...), but I can describe it the following way: when multiplexing is used, the ghosting is seen as the previously multiplexed (lit) layer turning off too slowly, so basically you see a ghost image (dim image) of the current layer in the previously lit layer. So, if you light up an LED in the bottom layer, you'll see the LED which is in the same column and in the top layer (bottom layer is lit after the top layer because the layers come after each other from bottom to top) dimly lit. If you light an LED in the second layer, you'll see the LED below it dimly lit. For the third layer the ghost will be in the second layer and so on.

@WonderTiger: Sure, you can check out my code here: http://iqjar.com/download/jar/LED_Cube/4x4x4/LEDQB_v0.4.ZIP (http://iqjar.com/download/jar/LED_Cube/4x4x4/LEDQB_v0.4.ZIP)
I've taken a slightly different approach. My animations are all generated on the fly, no patterns are stored anywhere. I also put great emphasis into keeping every part of the code in the place where it logically belongs, so I have lots of files and classes. So far it worked out well, we'll see how well it will work with the 8x8x8 cube... The part that writes the data out to the cube is in QBWriter.cpp, in the function QBWriter::sendOutputBuffer(). You'll see there that in the first step I shift all 0s into all the shift registers and then, if there's any non-zero data to be displayed, I first wait for 75 milliseconds (delayMicroseconds (TurnOffLatency); //Wait for everything to turn off). this is a software fix to get rid of the ghosting. I'd like a hardware fix though :(

Code: [Select]

void QBWriter::sendOutputBuffer () const
{
    //To get around the ghosting introduced by the slow turning off of the cathode columns, we first turn everything off and wait a little
    digitalWrite (PIN_SS, LOW); //Start transferring data   
    for (byte i = 0; i  <= N; ++i)
    {
        SPI.transfer (B00000000);
    }
    digitalWrite (PIN_SS, HIGH); //Done transferring data
   
    if (isOutputDataNonZero ())
    {
        delayMicroseconds (TurnOffLatency); //Wait for everything to turn off
 
        //Then we push out the contents of the output buffer to the LED cube   
        digitalWrite (PIN_SS, LOW); //Start transferring data
        for (byte i = 0; i  <= N; ++i)
        {
            SPI.transfer (mOutputBuffer[i]);
        }
        digitalWrite (PIN_SS, HIGH); //Done transferring data
    }
}
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: chromedome45 on Apr 06, 2013, 04:10 am
Hi, Hey Wonder Tiger do you have a schematic or building instructions for you 5x5x5 LED Cube? If so could you post it?
Title: Re: 3x3x3 LED cube, newbie questions (5x5x5 comming soon)
Post by: WonderTiger on Apr 06, 2013, 08:36 pm
Actually I don't have any schematics or instructions really :(. If you really need help I can make some instructions though, but a search on google maybe gives you more information?

Its long time ago I made a vid. This is due I was very busy with school ( i had to make a Graphical User Interface for a little project, which was a good learning experience!). Last week I finally had some time to rewrite a code for my LED cube, now I'm using a Interrupt service routine to multiplex my cube and I'm able to adjust the brightness of the LEDs which results in this :):

http://www.youtube.com/watch?v=_mEOX-k7gy4