Pages: 1 [2] 3 4 5   Go Down
Author Topic: My 3x3x3 and 5x5x5 LED cube  (Read 10158 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley!

sorry for the newbie questions, still in the learning process  smiley

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
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?)
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got my LED cube build today smiley-grin! 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:
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 smiley:
If anyone has some tips what I could do better on my code, feel free to let me know smiley.
Logged

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yay, working cube!
Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Another video smiley, 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):


edit:
this code has even less lines as the one that I showed 2 posts back smiley.
« Last Edit: January 30, 2013, 06:21:29 pm by WonderTiger » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep no problem(this code is a little different than showed in the video):

Code:
/* 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;
  }

Logged

Canberra Australia
Offline Offline
God Member
*****
Karma: 11
Posts: 518
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for sharing that code Arduino001 ... I like your work, well done  smiley-cool 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:
/* 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();
}

« Last Edit: February 01, 2013, 09:07:27 pm by Pedro147 » Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't know how, but Arduino001 should be me (WonderTiger),  Weird..... Thanks anyway for your positive reply smiley-grin! (and thanks ofcourse for sharing your code as well smiley-wink)
« Last Edit: February 02, 2013, 12:07:53 pm by WonderTiger » Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 646
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Canberra Australia
Offline Offline
God Member
*****
Karma: 11
Posts: 518
Hardcore Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 02, 2013, 02:20:07 pm by Pedro147 » Logged


Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley, 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.
« Last Edit: February 03, 2013, 04:57:35 am by WonderTiger » Logged

Pages: 1 [2] 3 4 5   Go Up
Jump to: