I love the LED Cube. There are some amazing projects done on the web around LED cubes. The RGB LED cubes are even better! But let’s start by looking into what goes into a basic 4x4x4 cube and how we could use it for a year 9-10 electronics outcome. You will need 64 LED lights ( I’ve used 3mm but you could use whatever is available, most common are the 5mm ones), 4 x 220ohm resistors, Arduino Uno, connector cables, some spare wire, soldering kit, piece of cardboard/wood and a drill. I followed a Youtube tutorial and so can you, but in this blog post I am going to write up some fine details of improving the design and what the code does.

Template

First test that that all LED’s light up using some power source, even a small button cell battery will do. Next, make a template for holding the LED lights in place. I made a square grid and evenly placed the lights out with a 2cm spacing in between. The orientation matters , so follow it carefully. Drill holes in the marked vertices of each square grid ( don’t make the hole too big as the LED lights will not hold firm and it will be harder to solder). Bend the LED terminals and try keeping the terminals straight as possible. Only after completing the cube I realised it would have been much straighter if from the start I had paid attention to bending them right. Repeat procedure 4 times and then solder them on top of each other, connecting all the negative terminals one above the other. These will go each into a digital/analog port as a ‘column’. Each layer becomes a ‘level’. Notice that the Resistors are connected to the positive terminals for each level, so when you want to turn them on, there is a specific way to code it to get it going. It took me a while to figure it out.

Leaning LED cube of Pisa

I used connector cables to hook it up wit the Arduino, but most others have made it on a vero board and wired it up. If I do it again, I will most likely do a ‘naked design’ straight into the Arduino, using something like brass wire and focus on the design to get it straight. Mohit Bhoite and Jill Praus would be my inspiration. You should check out their amazing electronic artwork on Twitter.

Now, the coding is the best part. There are so many opportunities to touch upon the DT curriculum here. As there are so many sequences you could do, the possibility of endless ‘for’ loops( get that?) , one of which I have shown below. They can create algorithms and programs, variables, selection using comparative and logical operators, create sequences, iteration, identify and debug issues, creating electronic environments, design and develop new prototypes, optimise tools (software like PlatformIO and VScode, as well as hardware- more LED lights and using Teensy with interrupts, looking at scaling the design, procedures and protocols to improve the quality of the outcome.

Many thanks to Technoreview85 for giving me the basic idea to make this cube. Watch his video if you want a step by step instruction: https://www.youtube.com/watch?v=4pzxR-ZhbJA


#include <Arduino.h>
int level[4] = {A0,A1,A2,A3}; //Initiallise and declare LED Layers
int column[16] = {A4,A5,0,1,2,3,4,5,6,7,8,9,10,11,12,13}; //Initialise and declare LED Rows
int time = 500;

void setup() {
  // put your setup code here, to run once:
  for(int i = 0; i < 16; i++) {
    pinMode(column[i], OUTPUT);  //Rows as output
  }
  for(int i = 0; i < 4; i++) {
    pinMode(level[i], OUTPUT);  //each level is an output
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  //blinky();
  //delay(1000);
  //allOff();
  //delay(1000);
 //columnOn(); //take off comment code to make the function run
 turnOnAndOffAllByColumnSideways();
}

//all off
void allOff() {
  for(int i=0; i < 16; i++) {
    digitalWrite(column[i], HIGH); //as the columns are not connected via the resistor, they dont come on.
  }
  for(int i = 0; i < 4; i++) {
    digitalWrite(level[i], LOW);
  }
}

//all on
void allOn() {
  
  for(int i = 0; i<16; i++)
  {
    digitalWrite(column[i], LOW);  //columns go off when you want to turn on everything.
  }
  //turning on layers
  for(int i = 0; i<4; i++)
  {
    digitalWrite(level[i], HIGH);
  }

}

void blinky() {
  for(int i = 0; i < 30; i++) {
  allOn();
  delay(200);
  allOff();
  delay(200);  
    
  }
}

void turnOnAndOffAllByColumnSideways()
{
  int x = 75;
  allOff();
  //turn on layers
  for(int i = 0; i<4; i++)
  {
    digitalWrite(level[i], 1); //You can also write HIGH instead of 1, and LOW for 0.
  }

  for(int y = 0; y<3; y++)
  {
    //turn on 0-3
    for(int i = 0; i<4; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn on 4-7
    for(int i = 4; i<8; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn on 8-11
    for(int i = 8; i<12; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn on 12-15
    for(int i = 12; i<16; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn off 0-3
    for(int i = 0; i<4; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn off 4-7
    for(int i = 4; i<8; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn off 8-11
    for(int i = 8; i<12; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn off 12-15
    for(int i = 12; i<16; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn on 12-15
    for(int i = 12; i<16; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn on 8-11
    for(int i = 8; i<12; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn on 4-7
    for(int i = 4; i<8; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn on 0-3
    for(int i = 0; i<4; i++)
    {
      digitalWrite(column[i], 0);
      delay(x);
    }
    //turn off 12-15
    for(int i = 12; i<16; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn off 8-11
    for(int i = 8; i<12; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn off 4-7
    for(int i = 4; i<8; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
    //turn off 0-3
    for(int i = 0; i<4; i++)
    {
      digitalWrite(column[i], 1);
      delay(x);
    }
  }

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments