Project tutorial
Interactive 4x4x4 LED cube

Interactive 4x4x4 LED cube © GPL3+

Using 64 LED to create a cube, it separates to 4 layers and every layer have 16 LED which is connecting each other layer.

  • 2,995 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Interactive LED Cube

Using 64 LED to create a cube, it separates to 4 layers and every layer have 16 LED which is connecting each other layer. And using LED as a light sensor for the interaction of the LED cube.

First Layer

1) Bend the legs of 16 LED’s, the cathode (short leg) to the left and the anode (long leg) down

2) Soldering the anode of one LED touches to the anode of another LED together.

3) Connect the 4 free anodes of LED to breadboard.

4) Connect 4 pieces of 560-ohm resistor to the free cathode of the 4 LED’s in your breadboard.

5) Run 4 wires from the anodes in your breadboard to Arduino’s serial ports 4 till 7.

6) Run 4 wires from the resistors in your breadboard to ports 0 till 3 on the Arduino.

7)Place a LED with the anode (long leg) in analog-port 0 and the cathode in GND of the Arduino.

8) Run the following code (Interactive_LED_cube_pt1) on Arduino.

Second Layer

1) Bend the free anodes (long leads) upwards for connect to the second layer.

2) Bend the legs of the 16 LED's the other way which is the anode bend to the left and cathode bend to down and soldering them together as first layer.

3) After that, solder the four anodes from the first layer to the four cathodes of the second layer.

4) The anodes of the second layer bends to the cathodes of the first layer and solder them together.

5) Connect them with the Arduino like before and run the following sketch (Interactive_LED_cube_pt1) and test again.

Third Layer

Third layer will be the same as the second layer

1) Only the inner two cathodes (short leads) need to be bended upwards.

2) Soldering the anodes of third layer to the bends of the cathodes of the second layer.

*So, it means that third layer will be turned 90 degrees counterclockwise from the second layer.

* Two outer cathodes need to be clear of the second layer.

Forth Layer

1) Solder the forth layer is the same way as the first layer, except the four corners of LEDs.

2) And all the leads will be bended down and soldered to the third layer.

3) Two anodes lead will be soldering to the upwards bended cathode-leads on the third layer.

Connections

1) The anodes of LED form first layer run 4 jumper wires to the digital pins 8-9-10-11 of the Arduino and the anodes of third layer 4 jumper wires to the digital pins 4-5-6-7 of Arduino.

2) The 4 resistor which connected to the cathodes of first layer run 4 jumper wires to digital pins 0-1-2-3 of the Arduino.

3) Soldering 4 jumper wires to the anodes of top 4 corner LED’s and connect to the analog pins A0 -A1-A2-A3 of Arduino.

4) Soldering 4 normal wire to the cathodes of top 4 corner LED’s and bend together. After that, connect to the GND of Arduino.

5) Run the Code(Interactive_LED_cube).

The final output of interactive LED cube

While LED sensor detect the brightness is lesser than the value of the sensor, it will show a light pattern.

Code

Interactive_LED_cubeJava
int tijd = 50; // set the speed
int tijdx = 0;

int basis1 = 0;
int basis2 = 0;
int basis3 = 0;
int basis4 = 0;
int sens1 = 0;
int sens2 = 0;
int sens3 = 0;
int sens4 = 0;
int x = 0;
int y = 0;
int totaal1 = 0;
int totaal2 = 0;
int totaal3 = 0;
int totaal4 = 0;

int map1 = 0;
int map2 = 0;
int map3 = 0;
int map4 = 0;

int led0 = 8;
int led1 = 9;
int led2 = 10;
int led3 = 11;
int led4 = 0; // nul
int led5 = 1; // nul
int led6 = 2; // nul
int led7 = 3; // nul
int led8 = 4;
int led9 = 5;
int led10 = 6;
int led11 = 7;


void setup()
{
pinMode(led0, INPUT);
pinMode(led1, INPUT);
pinMode(led2, INPUT);
pinMode(led3, INPUT);
pinMode(led4, INPUT);
pinMode(led5, INPUT);
pinMode(led6, INPUT);
pinMode(led7, INPUT);
pinMode(led8, INPUT);
pinMode(led9, INPUT);
pinMode(led10, INPUT);
pinMode(led11, INPUT);

// Serial.begin(9600);
}


void loop()
{
for(x =0; x < 50; x++)
{
sens1 = analogRead(0);
totaal1 = totaal1 + sens1;
sens2 = analogRead(1);
totaal2 = totaal2 + sens2;
sens3 = analogRead(2);
totaal3 = totaal3 + sens3;
sens4 = analogRead(3);
totaal4 = totaal4 + sens4;
}
sens1 = totaal1/x;
totaal1 = 0;
basis1 = sens1-20; // instellen van de gevoeligheid
sens2 = totaal2/x;
totaal2 = 0;
basis2 = sens2-20;
sens3 = totaal3/x;
totaal3 = 0;
basis3 = sens3-20;
sens4 = totaal4/x;
totaal4 = 0;
basis4 = sens4-20;


for(y=0;y<2000;y++){
for(x =0; x < 30; x++)
{
sens1 = analogRead(0);
sens2 = analogRead(1);
sens3 = analogRead(2);
sens4 = analogRead(3);

totaal1 = totaal1 + sens1;
totaal2 = totaal2 + sens2;
totaal3 = totaal3 + sens3;
totaal4 = totaal4 + sens4;
// delay(10);
}
sens1 = totaal1/x;
sens2 = totaal2/x;
sens3 = totaal3/x;
sens4 = totaal4/x;

if (sens1<basis1){
if (sens1 < ((sens2 + sens3 + sens4)/3.18))
splash1();
}

if (sens2<basis2){
if (sens2 < ((sens1 + sens3 + sens4)/3.18))
splash2();
}

if (sens3<basis3){
if (sens3 < ((sens1 + sens2 + sens4)/3.18))
splash3();
}

if (sens4<basis4){
if (sens4 < ((sens1 + sens3 + sens2)/3.18))
splash4();
}

totaal1 = 0;
totaal2 = 0;
totaal3 = 0;
totaal4 = 0;
delay(5);

/*
Serial.print(sens1, DEC); Serial.print(" - "); Serial.print(basis1, DEC);
Serial.println();
Serial.print(sens2, DEC); Serial.print(" - "); Serial.print(basis2, DEC);
Serial.println();
Serial.print(sens3, DEC); Serial.print(" - "); Serial.print(basis3, DEC);
Serial.println();
Serial.print(sens4, DEC); Serial.print(" - "); Serial.print(basis4, DEC);
Serial.println(); Serial.println();
*/
}


}

void splash1()
{
a4(); b4(); c4(); d4(); h4(); l4(); p4(); o4(); n4(); m4(); i4(); e4(); f4(); g4(); k4(); j4();
j3(); f3(); g3(); k3(); o3(); n3(); m3(); i3(); e3(); a3(); b3(); c3(); d3(); h3(); l3(); p3();
p2(); o2(); n2(); m2(); i2(); e2(); a2(); b2(); c2(); d2(); h2(); l2(); k2(); j2(); f2(); g2();
g1(); k1(); j1(); f1(); b1(); c1(); d1(); h1(); l1(); p1(); o1(); n1(); m1(); i1(); e1(); a1();
}

void splash2()
{
p4(); o4(); n4(); m4(); l4(); k4(); j4(); i4(); h4(); g4(); f4(); e4(); d4(); c4(); b4(); a4();
a3(); b3(); c3(); d3(); e3(); f3(); g3(); h3(); i3(); j3(); k3(); l3(); m3(); n3(); o3(); p3();
p2(); o2(); n2(); m2(); l2(); k2(); j2(); i2(); h2(); g2(); f2(); e2(); d2(); c2(); b2(); a2();
a1(); b1(); c1(); d1(); e1(); f1(); g1(); h1(); i1(); j1(); k1(); l1(); m1(); n1(); o1(); p1();
uit();
}

void splash3()
{
tijdx = tijd;
tijd = 0;
for (y = 0; y < 5 ; y++)
{
for (x = 0; x < tijdx/4 ; x++)
{
a1(); a2(); a3(); a4(); f1(); f2(); f3(); f4();
}
for (x = 0; x < tijdx/4 ; x++)
{
b1(); b2(); b3(); b4(); f1(); f2(); f3(); f4();
}
for (x = 0; x < tijdx/4 ; x++)
{
c1(); c2(); c3(); c4(); g1(); g2(); g3(); g4();
}
for (x = 0; x < tijdx/4 ; x++)
{
d1(); d2(); d3(); d4(); g1(); g2(); g3(); g4();
}
for (x = 0; x < tijdx/4 ; x++)
{
h1(); h2(); h3(); h4(); g1(); g2(); g3(); g4();
}
for (x = 0; x < tijdx/4 ; x++)
{
l1(); l2(); l3(); l4(); k1(); k2(); k3(); k4();
}
for (x = 0; x < tijdx/4 ; x++)
{
p1(); p2(); p3(); p4(); k1(); k2(); k3(); k4();
}
for (x = 0; x < tijdx/4 ; x++)
{
o1(); o2(); o3(); o4(); k1(); k2(); k3(); k4();
}
for (x = 0; x < tijdx/4 ; x++)
{
n1(); n2(); n3(); n4(); j1(); j2(); j3(); j4();
}
for (x = 0; x < tijdx/4 ; x++)
{
m1(); m2(); m3(); m4(); j1(); j2(); j3(); j4();
}
for (x = 0; x < tijdx/4 ; x++)
{
i1(); i2(); i3(); i4(); j1(); j2(); j3(); j4();
}
for (x = 0; x < tijdx/4 ; x++)
{
e1(); e2(); e3(); e4(); f1(); f2(); f3(); f4();
}
}
tijd = tijdx;
}

void splash4()
{
test();
}

void uit(){
pinMode(led0, INPUT);
pinMode(led1, INPUT);
pinMode(led2, INPUT);
pinMode(led3, INPUT);
pinMode(led4, INPUT);
pinMode(led5, INPUT);
pinMode(led6, INPUT);
pinMode(led7, INPUT);
pinMode(led8, INPUT);
pinMode(led9, INPUT);
pinMode(led10, INPUT);
pinMode(led11, INPUT);
pinMode(14, INPUT);
digitalWrite(14, LOW);
pinMode(15, INPUT);
digitalWrite(15, LOW);
pinMode(16, INPUT);
digitalWrite(16, LOW);
pinMode(17, INPUT);
digitalWrite(17, LOW);
}

void a1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void b1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void c1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void d1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void e1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void f1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void g1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void h1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void i1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void j1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void k1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void l1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void m1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void n1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void o1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void p1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void a2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void b2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void c2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void d2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void e2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void f2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void g2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void h2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void i2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void j2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void k2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void l2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void m2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void n2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void o2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void p2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void a3(){
pinMode(led8, OUTPUT);
digitalWrite(led8, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void b3(){
pinMode(led9, OUTPUT);
digitalWrite(led9, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void c3(){
pinMode(led10, OUTPUT);
digitalWrite(led10, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void d3(){
pinMode(led11, OUTPUT);
digitalWrite(led11, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void e3(){
pinMode(led8, OUTPUT);
digitalWrite(led8, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void f3(){
pinMode(led9, OUTPUT);
digitalWrite(led9, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void g3(){
pinMode(led10, OUTPUT);
digitalWrite(led10, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void h3(){
pinMode(led11, OUTPUT);
digitalWrite(led11, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void i3(){
pinMode(led8, OUTPUT);
digitalWrite(led8, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void j3(){
pinMode(led9, OUTPUT);
digitalWrite(led9, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void k3(){
pinMode(led10, OUTPUT);
digitalWrite(led10, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void l3(){
pinMode(led11, OUTPUT);
digitalWrite(led11, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void m3(){
pinMode(led8, OUTPUT);
digitalWrite(led8, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void n3(){
pinMode(led9, OUTPUT);
digitalWrite(led9, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void o3(){
pinMode(led10, OUTPUT);
digitalWrite(led10, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void p3(){
pinMode(led11, OUTPUT);
digitalWrite(led11, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);

uit();
}

void a4(){
digitalWrite(14, HIGH);
pinMode(14, OUTPUT);
digitalWrite(14, HIGH);
delay (tijd);
uit();

}

void b4(){
pinMode(led9, OUTPUT);
digitalWrite(led9, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void c4(){
pinMode(led10, OUTPUT);
digitalWrite(led10, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void d4(){
digitalWrite(15, HIGH);
pinMode(15, OUTPUT);
digitalWrite(15, HIGH);
delay (tijd);
uit();
}

void e4(){
pinMode(led8, OUTPUT);
digitalWrite(led8, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void f4(){
pinMode(led9, OUTPUT);
digitalWrite(led9, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void g4(){
pinMode(led10, OUTPUT);
digitalWrite(led10, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void h4(){
pinMode(led11, OUTPUT);
digitalWrite(led11, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void i4(){
pinMode(led8, OUTPUT);
digitalWrite(led8, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void j4(){
pinMode(led9, OUTPUT);
digitalWrite(led9, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void k4(){
pinMode(led10, OUTPUT);
digitalWrite(led10, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void l4(){
pinMode(led11, OUTPUT);
digitalWrite(led11, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void m4(){
digitalWrite(17, HIGH);
pinMode(17, OUTPUT);
digitalWrite(17, HIGH);
delay (tijd);
uit();
}

void n4(){
pinMode(led9, OUTPUT);
digitalWrite(led9, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void o4(){
pinMode(led10, OUTPUT);
digitalWrite(led10, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void p4(){
digitalWrite(16, HIGH);
pinMode(16, OUTPUT);
digitalWrite(16, HIGH);
delay (tijd);
uit();
}



void test(){
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, INPUT);
pinMode(led9, INPUT);
pinMode(led10, INPUT);
pinMode(led11, INPUT);

digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);

digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay (tijd*4);

digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd*4);

pinMode(led0, INPUT);
pinMode(led1, INPUT);
pinMode(led2, INPUT);
pinMode(led3, INPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(led11, OUTPUT);

digitalWrite(led8, LOW);
digitalWrite(led9, LOW);
digitalWrite(led10, LOW);
digitalWrite(led11, LOW);

digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay (tijd*4);

digitalWrite(led8, HIGH);
digitalWrite(led9, HIGH);
digitalWrite(led10, HIGH);
digitalWrite(led11, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd*4);
uit();

}  
Interactive_LED_cube_pt1Java
int basis = 0;
int sens = 0;
int x = 0;
int y = 0;
int totaal = 0;
int totaal1 = 0;

int led0 = 0;
int led1 = 1;
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int tijd = 300;



void setup() {

pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);

}


void loop()
{
for(x =0; x < 50; x++)
{
sens = analogRead(0);
totaal = totaal1 + sens;
totaal1 = totaal;
}
sens = totaal/x;
totaal = 0;
totaal1 = 0;
basis = sens-20; // instellen van de gevoeligheid
for(y=0;y<1000;y++){
for(x =0; x < 50; x++)
{
sens = analogRead(0);
totaal = totaal1 + sens;
totaal1 = totaal;
delay(10);
}
sens = totaal/x;
if (sens<basis)
splash1();

totaal = 0;
totaal1 = 0;

delay(10);
}

}

void splash1(){

test();
a();
b();
c();
d();
e();
f();
g();
h();
i();
j();
k();
l();
m();
n();
o();
p();
uit();
}

void uit(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void a(){
digitalWrite(led0, LOW);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void b(){
digitalWrite(led0, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void c(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);

digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void d(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);

digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void e(){
digitalWrite(led0, LOW);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void f(){
digitalWrite(led0, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void g(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void h(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);

digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (tijd);
}

void i(){
digitalWrite(led0, LOW);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
delay (tijd);
}

void j(){
digitalWrite(led0, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
delay (tijd);
}

void k(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
delay (tijd);
}

void l(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led7, LOW);
delay (tijd);
}

void m(){
digitalWrite(led0, LOW);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, HIGH);
delay (tijd);
}

void n(){
digitalWrite(led0, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, HIGH);
delay (tijd);
}

void o(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, HIGH);
delay (tijd);
}

void p(){
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, HIGH);
delay (tijd);
}

void test(){
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);

digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay (1000);
}               
Interactive_LED_cube_pt2Java
int basis = 0;
int sens = 0;
int x = 0;
int y = 0;
int totaal = 0;
int totaal1 = 0;

int led0 = 0;
int led1 = 1;
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int tijd = 100;



void setup() {

pinMode(led0, INPUT);
pinMode(led1, INPUT);
pinMode(led2, INPUT);
pinMode(led3, INPUT);
pinMode(led4, INPUT);
pinMode(led5, INPUT);
pinMode(led6, INPUT);
pinMode(led7, INPUT);

}


void loop()
{
for(x =0; x < 50; x++)
{
sens = analogRead(0);
totaal = totaal1 + sens;
totaal1 = totaal;
}
sens = totaal/x;
totaal = 0;
totaal1 = 0;
basis = sens-20; // instellen van de gevoeligheid
for(y=0;y<1000;y++){
for(x =0; x < 50; x++)
{
sens = analogRead(0);
totaal = totaal1 + sens;
totaal1 = totaal;
delay(10);
}
sens = totaal/x;
if (sens<basis)
splash1();

totaal = 0;
totaal1 = 0;

delay(10);
}

}

void splash1(){

test();
a1(); b1(); c1(); d1(); e1(); f1(); g1(); h1(); i1(); j1(); k1(); l1(); m1(); n1(); o1(); p1();
p2(); o2(); n2(); m2(); l2(); k2(); j2(); i2(); h2(); g2(); f2(); e2(); d2(); c2(); b2(); a2();
uit();
delay (tijd);
}

void uit(){
pinMode(led0, INPUT);
pinMode(led1, INPUT);
pinMode(led2, INPUT);
pinMode(led3, INPUT);
pinMode(led4, INPUT);
pinMode(led5, INPUT);
pinMode(led6, INPUT);
pinMode(led7, INPUT);
}

void a1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void b1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void c1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void d1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led4, OUTPUT);
digitalWrite(led4, HIGH);
delay (tijd);
uit();
}

void e1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void f1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void g1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void h1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led5, OUTPUT);
digitalWrite(led5, HIGH);
delay (tijd);
uit();
}

void i1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void j1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void k1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void l1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led6, OUTPUT);
digitalWrite(led6, HIGH);
delay (tijd);
uit();
}

void m1(){
pinMode(led0, OUTPUT);
digitalWrite(led0, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void n1(){
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void o1(){
pinMode(led2, OUTPUT);
digitalWrite(led2, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void p1(){
pinMode(led3, OUTPUT);
digitalWrite(led3, LOW);
pinMode(led7, OUTPUT);
digitalWrite(led7, HIGH);
delay (tijd);
uit();
}

void a2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void b2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void c2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void d2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led4, OUTPUT);
digitalWrite(led4, LOW);
delay (tijd);
uit();
}

void e2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void f2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void g2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void h2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led5, OUTPUT);
digitalWrite(led5, LOW);
delay (tijd);
uit();
}

void i2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void j2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void k2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void l2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led6, OUTPUT);
digitalWrite(led6, LOW);
delay (tijd);
uit();
}

void m2(){
pinMode(led0, OUTPUT);
digitalWrite(led0, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void n2(){
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void o2(){
pinMode(led2, OUTPUT);
digitalWrite(led2, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}

void p2(){
pinMode(led3, OUTPUT);
digitalWrite(led3, HIGH);
pinMode(led7, OUTPUT);
digitalWrite(led7, LOW);
delay (tijd);
uit();
}


void test(){
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);

digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
delay (1000);
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);

digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
delay (1000);
uit();
}               

Schematics

Interactive 4x4x4 LED cube
F8per69gs3bfdue medium 20nigmsszt

Comments

Similar projects you might like

4x4x4 LED cube with Arduino Uno and 1sheeld

Project tutorial by Hassan Ibrahim

  • 35,855 views
  • 7 comments
  • 64 respects

LED CUBE 4x4x4

Project showcase by MakerRobotics

  • 43,350 views
  • 8 comments
  • 80 respects

LED Cube

Project tutorial by Praditha Alwis

  • 11,400 views
  • 0 comments
  • 18 respects

Interactive LED Name

Project tutorial by Pedro Mendez and Daniel Jablonski

  • 2,960 views
  • 2 comments
  • 7 respects

4*4*4 LED Cube Using Arduino Embedded Prototyping Platform

Project tutorial by STEMpedia

  • 3,323 views
  • 1 comment
  • 11 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 28,519 views
  • 6 comments
  • 54 respects
Add projectSign up / Login