Trybotics Logo

LED Cube 3x3x3 With Arduino

DESCRIPTION

In this tutorial I’ll show how you can create your own LED Cube 3x3x3

Parts required:1x Arduino

27x LED's

9x 220 ohm Resistors

3x NPN Transistors (for example: 2N2222, BC547, 2N3904)

Wire

Description:

Description:

First, you will need a piece of cardboard with 9 holes as shown above. Place 9 LED's into the nine holes so that their negative leads(the shorter lead on the flat side of the LED) are all facing the outside of the square and bend them down so that they are all touching. Solder all of the leads together and remove the LED's from the cardboard to make one level of the cube. Repeat three times. Each level of LED's should have all of the negative leads soldered together with the positive leads sticking downwards.

Description:

Now you will need to stack all three layers and solder their positive leads together. You may need to bend the leads inwards and play around with it to get each layer's leads to touch. When you're done, you should have every LED's negative lead connected to the negative leads of all of the other LED's in its layer while every LED's positive lead is connected to the positive leads of all of the other LED's in its column. Make sure that no positive leads cross with negative leads or you could get a short circuit.

Description:

Here is code

void setup() {
for (int i = 1; i <= 9; i++) pinMode(i, OUTPUT); for (int i = 10; i <=12; i++) digitalWrite(i, HIGH); } void loop() { int del = 100;

//flashes LED's from top to bottom for (int i = 0; i <= 3; i++) { for (int i = 0; i <= 10; i++) digitalWrite(i, HIGH); for (int i = 11; i <= 13; i++) { digitalWrite(i, LOW); delay(del); } for (int i = 11; i <= 13; i++) { digitalWrite(i, HIGH); delay(del); } } //flashes LED's in a downwards spiral for (int i = 0; i <= 10; i++) digitalWrite(i, LOW); for (int i = 0; i < 3; i++) { flash(del, 0, 0, i); flash(del, 1, 0, i); flash(del, 2, 0, i); flash(del, 2, 1, i); flash(del, 2, 2, i); flash(del, 1, 2, i); flash(del, 0, 2, i); flash(del, 0, 1, i); } //flashes LED's in one random column from top to bottom for (int i = 0; i <= 9; i++) { int x = random(3); int y = random(3); for (int i = 0; i <= 2; i++) { flash(del+50, x, y, i); } delay(del); } //randomly flashes LED's for (int i = 0; i <= 200; i++) { int x = random(3); int y = random(3); int z = random(3); flash(10, x, y, z); } //flashes LED's from one corner outwards for (int i = 0; i <= 3; i++) { flash(2*del, 0, 0, 0); for (int i = 2*(del/7); i >= 0; i--) { flash(1, 0, 1, 0); flash(1, 1, 1, 0); flash(1, 1, 0, 0); flash(1, 0, 0, 1); flash(1, 0, 1, 1); flash(1, 1, 1, 1); flash(1, 1, 0, 1); } for (int i = 2*(del/19); i >= 0; i--) { flash(1, 0, 2, 0); flash(1, 1, 2, 0); flash(1, 2, 2, 0); flash(1, 2, 1, 0); flash(1, 2, 0, 0); flash(1, 0, 2, 1); flash(1, 1, 2, 1); flash(1, 2, 2, 1); flash(1, 2, 1, 1); flash(1, 2, 0, 1); flash(1, 0, 0, 2); flash(1, 0, 1, 2); flash(1, 0, 2, 2); flash(1, 1, 0, 2); flash(1, 1, 1, 2); flash(1, 1, 2, 2); flash(1, 2, 0, 2); flash(1, 2, 1, 2); flash(1, 2, 2, 2); } } } void onOff(boolean state, int x, int y, int z) { //turns on or off led at (x, y, z) if (state) { digitalWrite(z+11, LOW); digitalWrite((3*x)+y+2, HIGH); } else { digitalWrite(z+11, HIGH); digitalWrite((3*x)+y+2, LOW); } } void flash(int msec, int x, int y, int z) { //flashes led at (x, y, z) on and off for msec onOff(true, x, y, z); //milliseconds delay(msec); onOff(false, x, y, z); }

Description:

YOU MIGHT ALSO LIKE