Companion Cube

Duncan Miller

Brian Moore

The prototype v2 Companion Cube is the latest design production from Amateur science labs. It features a base structure of 3 by 3 LEDs that can be controlled individually with only 12 pins. The number of sequence possibilities are endless and can entertain you for hours. It can blink, flash, strobe, and cheer you up when you are unhappy. The color variations come in any color you want, as long as it is red. The shade of the red LEDs perfectly accent the bread board, but really it just costs less. Eight out of ten scientists suspect that it cannot feel pain, so you do not need to worry about dropping it or incinerating it in a deadly inferno. We take the time to remind you that the cube cannot talk, but if it does, please disregard its advice.

int x = 1;

int y=2;

int z=3;

int a=4;

int b=5;

int c=6;

int d=7;

int e=8;

int f=9;

int g=10;

int h=11;

int i=12;

void setup(){

for (int w=1; w<=13; w++)

{pinMode(w, OUTPUT);}

}

void off()

{

for (int w=1; w<=13; w++)

{pinMode(w, INPUT);}

}

void led1()

{

pinMode (z, OUTPUT);

pinMode (i, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (i, HIGH);}

void led2()

{ pinMode (z, OUTPUT);

pinMode (d, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (d, HIGH);}

void led3()

{ pinMode (z, OUTPUT);

pinMode (a, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (a, HIGH);}

void led4()

{ pinMode (z, OUTPUT);

pinMode (g, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (g, HIGH);}

void led5()

{ pinMode (z, OUTPUT);

pinMode (f, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (f, HIGH);}

void led6()

{ pinMode (z, OUTPUT);

pinMode (b, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (b, HIGH);}

void led7()

{ pinMode (z, OUTPUT);

pinMode (h, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (h, HIGH);}

void led8()

{ pinMode (z, OUTPUT);

pinMode (e, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (e, HIGH);}

void led9()

{ pinMode (z, OUTPUT);

pinMode (c, OUTPUT);

digitalWrite (z, LOW);

digitalWrite (c, HIGH);}

void led10()

{ pinMode (y, OUTPUT);

pinMode (i, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (i, HIGH);}

void led11()

{ pinMode (y, OUTPUT);

pinMode (d, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (d, HIGH);}

void led12()

{ pinMode (y, OUTPUT);

pinMode (a, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (a, HIGH);}

void led13()

{ pinMode (y, OUTPUT);

pinMode (g, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (g, HIGH);}

void led14()

{ pinMode (y, OUTPUT);

pinMode (f, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (f, HIGH);}

void led15()

{ pinMode (y, OUTPUT);

pinMode (b, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (b, HIGH);}

void led16()

{ pinMode (y, OUTPUT);

pinMode (h, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (h, HIGH);}

void led17()

{ pinMode (y, OUTPUT);

pinMode (e, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (e, HIGH);}

void led18()

{ pinMode (y, OUTPUT);

pinMode (c, OUTPUT);

digitalWrite (y, LOW);

digitalWrite (c, HIGH);}

void led19()

{ pinMode (x, OUTPUT);

pinMode (i, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (i, HIGH);}

void led20()

{ pinMode (x, OUTPUT);

pinMode (d, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (d, HIGH);}

void led21()

{ pinMode (x, OUTPUT);

pinMode (a, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (a, HIGH);}

void led22()

{ pinMode (x, OUTPUT);

pinMode (g, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (g, HIGH);}

void led23()

{ pinMode (x, OUTPUT);

pinMode (f, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (f, HIGH);}

void led24()

{ pinMode (x, OUTPUT);

pinMode (b, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (b, HIGH);}

void led25()

{ pinMode (x, OUTPUT);

pinMode (h, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (h, HIGH);}

void led26()

{ pinMode (x, OUTPUT);

pinMode (e, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (e, HIGH);}

void led27()

{ pinMode (x, OUTPUT);

pinMode (c, OUTPUT);

digitalWrite (x, LOW);

digitalWrite (c, HIGH);}

void all()

{for (int w=1; w<=13; w++)

{pinMode(w, OUTPUT);}

for (int w=4; w<=12; w++)

{digitalWrite (w, HIGH);}

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void botlay()

{pinMode (x, OUTPUT);

digitalWrite (x, LOW);

pinMode (y, INPUT);

pinMode (z, INPUT);

for (int w=4; w<=12; w++)

{pinMode(w,OUTPUT);

digitalWrite (w, HIGH);}}

void midlay()

{pinMode (y, OUTPUT);

digitalWrite (y, LOW);

pinMode (x, INPUT);

pinMode (z, INPUT);

for (int w=4; w<=12; w++)

{pinMode(w, OUTPUT);

digitalWrite (w, HIGH);}}

void toplay()

{pinMode (z, OUTPUT);

digitalWrite (z, LOW);

pinMode (x, INPUT);

pinMode (y, INPUT);

for (int w=4; w<=12; w++)

{pinMode(w, OUTPUT);

digitalWrite (w, HIGH);}}

void col1()

{pinMode (i, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (i, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col2()

{pinMode (d, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (d, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col3()

{pinMode (a, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (a, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col4()

{pinMode (g, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (g, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col5()

{pinMode (f, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (f, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col6()

{pinMode (b, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (b, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col7()

{pinMode (h, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (h, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col8()

{pinMode (e, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (e, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void col9()

{pinMode (c, OUTPUT);

pinMode (x, OUTPUT);

pinMode (y, OUTPUT);

pinMode (z, OUTPUT);

digitalWrite (c, HIGH);

digitalWrite (x, LOW);

digitalWrite (y, LOW);

digitalWrite (z, LOW);}

void loop()

{

off();

led1();

delay(650);

led10();

delay(650);

led19();

delay(650);

off();

col1 ();

delay (175);

off();

col2 ();

delay (175);

off();

col3 ();

delay (175);

off();

col6 ();

delay (175);

off();

col9 ();

delay (175);

off();

col8 ();

delay (175);

off();

col7 ();

delay (175);

off();

col4 ();

delay (175);

off(); // first

col1();

delay (175);

off();

col2 ();

delay (175);

off();

col2 ();

col3 ();

delay (175);

off();

col2 ();

col6 ();

delay (175);

off();

col2 ();

col9 ();

delay (175);

off();

col2 ();

col8 ();

delay (175);

off();

col2 ();

col7 ();

delay (175);

off();

col2 ();

col4 ();

delay (175);

off(); // second

col2 ();

col1 ();

delay (175);

off();

col2 ();

delay (175);

off();

col2 ();

col3 ();

delay (175);

off();

col2 ();

col6 ();

delay (175);

off();

col2 ();

col6 ();

col9 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

delay (175);

off();

col2 ();

col6 ();

col7 ();

delay (175);

off();

col2 ();

col6 ();

col4 ();

delay (175);

off(); // third

col2 ();

col6 ();

col1 ();

col2 ();

col6 ();

delay (175);

off();

col6 ();

col2 ();

delay (175);

off();

col2 ();

col6 ();

col3 ();

delay (175);

off();

col2 ();

col6 ();

delay (175);

off();

col9 ();

col2 ();

col6 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

col7 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

col4 ();

delay (175);

off(); // fourth

col2 ();

col6 ();

col8 ();

col1 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

delay (175);

off();

col3 ();

col2 ();

col6 ();

col8 ();

delay (175);

off();

col6 ();

col2 ();

col8 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

col9 ();

delay (175);

off();

col2 ();

col6 ();

col8 ();

delay (175);

off();

col7 ();

col2 ();

col6 ();

col8 ();

delay (175);

off();

col4 ();

col2 ();

col6 ();

col8 ();

delay (175);

off(); // last

delay(200);

col2 ();

col6 ();

col8 ();

col4();

delay(250);

off();

delay(200);

col2 ();

col6 ();

col8 ();

col4();

delay(250);

off();

delay(200); // blinks

col2 ();

col6 ();

col8 ();

col4();

delay(600);

off();

col5();

delay(110);

off();

delay(105);

col5();

delay(100);

off();

delay(95);

col5();

delay(90);

off();

delay(85);

col5();

delay(80);

off();

delay(80);

col5();

delay(80);

off();

delay(80);

col5();

delay(80);

off(); // col6 blinks

toplay();

for(int w=1; w<=250; w++){

toplay();

delay(1);

off();

col5();

delay(1);

off();

} // top layer

for(int w=1; w<=250; w++){

midlay();

delay(1);

off();

led14();

led23();

delay(1);

off();

}

botlay();

delay(500);

off();

delay(5000);

}