3X3X3 Led Cube Homework Using Arduino Uno

Thread Starter

MERT CAN YAMAN

Joined Oct 25, 2017
4
Hello my dear friends, I have to make 3x3x3 led cube for my homework on which each led have to be blinking respectively at first, and then each surface will respectively be lighted up and finally the cube will completely be lighted up. I've made its simulation on Proteus 8 and already written its code on Arduino IDE,however, I've encountered a tedious problem which takes my hours. I've only succeeded the respectively blinking and to light up top-bottom surfaces ,but I can't light up the side surfaces and also entire cube although I've tried many different code variations. I will be so glad if you help me, I have to make this homework to pass this lesson. Thanks in advance.

My proteus drawing and arduino code are in the attachment. In that of the proteus, each leds inside of a square represent a layer of the cube.
 

Attachments

dl324

Joined Mar 30, 2015
16,913
Welcome to AAC!

Post your schematic and describe what the program attempts to do.

I'm not going to open the .rar file.
 

WBahn

Joined Mar 31, 2012
30,048
I would recommend setting up your code so that you have a bit field in which each bit is mapped to one of the LEDs. You need 27 bits, so a 32-bit integer is more than enough.

Have one part of your code turn on the LEDs based on the values in that integer.

Now the rest of your code is a simple matter of constructing the value to be stored in that integer. A pretty easy way to do that is to build a function that takes the x,y,z positions of the LED within the cube as well as a boolean that says whether you want it on or off and then bit bangs that integer to set/clear the appropriate bit.
 

Thread Starter

MERT CAN YAMAN

Joined Oct 25, 2017
4
You only get one chance to make a good first impression. You wasted yours.

Explain what you want your code to do and what it's actually doing.
I have first time used proteus for a simulation, I've learnt a short and great way about how to draw easily thanks to my helpful friend absf, and also I've realized that i drew it so sloppy. I expressed my gratitude to him saying thank you so much. He fixed the complexity of the circuit and now I've been asking how i can fix my mistakes on the code. As I expressed it before, I couldn't light up both the sides of cubes and all leds with my code. I am so sorry if there is a misunderstanding here.
 
Last edited:

nerdegutta

Joined Dec 15, 2009
2,684
Hi.

Not many people will open up source code... I boldly took the chance to copy your code in to this post, using the CODE - tag.

Code:
int Columnas[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int Filas[] = {10,11,12};

void setup(){
int contador;
for (int contador=0; contador<9; contador++){
pinMode(Columnas[contador], OUTPUT); }
for (int contador=0; contador<3; contador++){
pinMode(Filas[contador], OUTPUT); }
}
void loop(){
int sayac;
// These following codes are for respectively blinking //
digitalWrite(Filas[0], HIGH);
  for(sayac=0;sayac<9;sayac++){
    digitalWrite(Columnas[sayac], HIGH);
    delay(1000);
    digitalWrite(Columnas[sayac], LOW);
  }
digitalWrite(Filas[0], LOW);
digitalWrite(Filas[1], HIGH);
for(sayac=0;sayac<9;sayac++){
    digitalWrite(Columnas[sayac], HIGH);
    delay(1000);
    digitalWrite(Columnas[sayac], LOW);
  }
digitalWrite(Filas[1], LOW);
digitalWrite(Filas[2], HIGH);
for(sayac=0;sayac<9;sayac++){
    digitalWrite(Columnas[sayac], HIGH);
    delay(1000);
    digitalWrite(Columnas[sayac], LOW);
  }
digitalWrite(Filas[2], LOW);
digitalWrite(Filas[0], HIGH); // On the left, It is for the bottom surface.  //
for(sayac=0;sayac<9;sayac++){
    digitalWrite(Columnas[sayac], HIGH);
  }
delay(3000);
digitalWrite(Filas[0], LOW);

// these followings are for sides //
digitalWrite(Columnas[0],HIGH);
digitalWrite(Columnas[1],HIGH);
digitalWrite(Columnas[2], HIGH);
delay(3000);
digitalWrite(Columnas[0],LOW);
digitalWrite(Columnas[1],LOW);
digitalWrite(Columnas[2], LOW);

digitalWrite(Columnas[6],HIGH);
digitalWrite(Columnas[7],HIGH);
digitalWrite(Columnas[8], HIGH);
delay(3000);
digitalWrite(Columnas[6],LOW);
digitalWrite(Columnas[7],LOW);
digitalWrite(Columnas[8], LOW);


digitalWrite(Columnas[0],HIGH);
digitalWrite(Columnas[3],HIGH);
digitalWrite(Columnas[6], HIGH);
delay(3000);
digitalWrite(Columnas[0],LOW);
digitalWrite(Columnas[3],LOW);
digitalWrite(Columnas[6], LOW);

digitalWrite(Columnas[2],HIGH);
digitalWrite(Columnas[5],HIGH);
digitalWrite(Columnas[8], HIGH);
delay(3000);
digitalWrite(Columnas[2], LOW);
digitalWrite(Columnas[5], LOW);
digitalWrite(Columnas[8], LOW);

digitalWrite(Filas[2], HIGH); //on the left, Its for the top surface //
for(sayac=0;sayac<9;sayac++){
    digitalWrite(Columnas[sayac], HIGH);
  }
  delay(3000);
digitalWrite(Filas[2], LOW);

digitalWrite(Filas[0], HIGH); //entire cube //
digitalWrite(Filas[1], HIGH);
digitalWrite(Filas[2], HIGH);
delay(8000);
digitalWrite(Filas[0], LOW);
digitalWrite(Filas[1], LOW);
digitalWrite(Filas[2], LOW);




for(;;);

  }
 

WBahn

Joined Mar 31, 2012
30,048
It would be very nice if the code was reasonably and consistently formatted.

It would also be nice to have the definition of this 'digitalWrite()' function that is called so often.
 

Thread Starter

MERT CAN YAMAN

Joined Oct 25, 2017
4
Thank you so much, nerdegutta. I am new here, I didn't know how i could post correctly depending on forum rules, but it won't be like that next time.
 
Top