On this tutorial, I’ll information you step-by-step on easy methods to create and fabricate a 5x5x5 LED dice utilizing Arduino Mega. This tutorial can even cowl all the basics required to make a 5x5x5 LED dice, like easy methods to create a 3D association utilizing LEDs, easy methods to create completely different animations and patterns, working of the circuit and code, board and pin configuration of Arduino Mega.
Board configuration of Arduino Mega
Pin Configuration of Arduino Mega
Digital I/O Pins: D0-D53
Analog Enter Pins: A0-A15
PWM Pins: 2 – 13, 44 – 46
I2C pins: SDA(20), SCL(21)
SPI pins: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS)
UART Pins:
- TX0-D0, RX0- D1
- TX1-D19, RX1-D18
- TX2-D16, RX2-D17
- TX3-D14, RX3-D15
Options of Arduino Mega
- Working Voltage: 5V
- Enter Voltage: 6-20V
- Working Present:
- Output Voltage: 3.3V and 5V
- Output Present: 20mA(5V) and 50mA(3.3V)
- Digital I/O pins: 54
- ADC pins: 16
- PWM pins: 15
- UART: 4
Elements required for this challenge
- Arduino Mega – 1
- LEDs (Any Colour)- 125
- Resistor 220 ohm- 30
- Jumper wires
- Soldering wire
- Soldering Iron
Working of the challenge
This LED dice consists of a complete of 125 LEDs. We’ll management every LED with the assistance of an Arduino Mega board. For controlling all of the LED current within the LED dice, we have now divided this dice into 5 layers and 25 columns. The layers are layer0, layer1, layer2, layer3, and layer 4. Every layer consists of 25 LEDs and the destructive terminal of all of the LEDs current in a selected layer are related to one another. Equally, all the opposite layer consists of the identical variety of LEDs and the destructive terminal of all of the LEDs are related to one another.
Then we have now 25 columns ranging from c0, c2, c3, c4, c5………..c24. Column c0 consists of LEDs from layer0, layer1, layer2, layer3, and layer4, and the optimistic terminal of all these LEDs are related to one another. Equally, all the opposite columns are related in the identical method.
So, every LED has a singular place within the LED dice that may be specified by the layer and column quantity. Like, the primary LED of the dice is (layer0,c0). equally 2nd LED of the dice is (layer0,c1) and so forth.
Suppose if you wish to flip ON the primary LED then you must join the layer0 to the GND and c0 to the 5V. Equally, if you wish to activate the final LED then you must join the layer4 to the GND and c24 to the 5V. Likewise, you possibly can flip ON and OFF all of the LEDs.
Observe the next steps for making a 5x5x5 LED dice
Step1: Take a look at all of the LEDs one after the other and ensure all of the LEDs are working. That is an important step of all as a result of it’s actually arduous to interchange the LED with the dice is completed. You should use a breadboard for this objective as proven within the determine.
Step2: Take a cardboard nd make 125 holes as proven within the image. You should use a drill machine for this objective. The opening ought to of 5mm in diameter.
Step3: Bent the destructive terminal of all of the LEDs as proven within the image.
Step4: Insert all of the 25 LEDs into the opening.
Step5: Solder the destructive terminal of all of the LEDs current within the first row.
Step6: Solder all the opposite rows in the identical method.
Step7: Now, join all of the rows utilizing a silver wire.
Step8: You need to create 4 extra layers like this. In whole we’d like 5 layers.
Step9: Join all of the columns one after the other. You’ll be able to place a carboard piece between the layer for simple soldering. Keep in mind that there are 25 columns.
Step10: After connecting all of the columns and layers, you’re going to get 5 layers and 25 columns.
Step11: Join all of the layers and columns to the Arduino Mega Board
Step12: Add the code to the Arduino Mega Board
int layerPin[5]=13,12,11,10,9;
int columnPin[25]=2,3,4,5,6,7,8,14,15,16,17,18,19,21,22,23,24,25,26,27,28,29,30,31;
void setup()
for(int i=0;i<5;i++)
pinMode(layerPin[i],OUTPUT);
for(int i=0;i<25;i++)
pinMode(columnPin[i],OUTPUT);
for(int i=0;i<5;i++)
digitalWrite(layerPin[i],HIGH);
void loop()
animation1();
clearPin();
animation2();
void clearPin()
for(int i=0;i<5;i++)
digitalWrite(layerPin[i],HIGH);
for(int i=0;i<25;i++)
digitalWrite(columnPin[i],LOW);
void animation1()
for(int i=0;i<25;i++)
digitalWrite(columnPin[i],HIGH);
for(int y=0;y<5;y++)
digitalWrite(layerPin[i],LOW);
delay(1000);
digitalWrite(layerPin[i],HIGH);
delay(1000);
digitalWrite(columnPin[i],LOW);
void animation2()
for(int i=0;i<5;i++)
digitalWrite(layerPin[i],LOW);
for(int y=0;y<25;y++)
digitalWrite(columnPin[i],HIGH);
delay(1000);
for(int y=0;y<25;y++)
digitalWrite(columnPin[i],LOW);
delay(1000);
digitalWrite(layerPin[i],HIGH);
Working of code
Outline all of the layer pins first. For that I’ve created an array named layerPin and saved all of the pin quantity inside it.
int layerPin[5]=13,12,11,10,9;
Outline all of the pins for columns. For that, I’ve created an array named columnPin and saved all of the pin numbers inside it.
int columnPin[25]=2,3,4,5,6,7,8,14,15,16,17,18,19,21,22,23,24,25,26,27,28,29,30,31;
Contained in the void setup(), first set all of the layer pin as OUTPUT uisng a for loop.
void setup() {
for(int i=0;i<5;i++)
pinMode(layerPin[i],OUTPUT);
Equally, set all of the column pins as OUTPUT utilizing a for loop.
for(int i=0;i<25;i++)
pinMode(columnPin[i],OUTPUT);
Set all of the layer pins as HIGH as a result of once you use the pinMode() perform, by default all of the pins are set to LOW. We now have related the destructive terminal of all of the LEDs to those layer pins. So, we have now to make them HIGH.
for(int i=0;i<5;i++)
digitalWrite(layerPin[i],HIGH);
It is a perform to set all of the columns and layer pins to the default state. The layer pins have to be set to HIGH and column pins have to be set to LOW as a way to flip OFF the LED. This perform will assist in shifting from one sample to a different.
void clearPin()
for(int i=0;i<5;i++)
digitalWrite(layerPin[i],HIGH);
for(int i=0;i<25;i++)
digitalWrite(columnPin[i],LOW);
That is one other perform, I’ve created this for producing the primary animation. On this animation all of the LEDs will flip ON and OFF one after the other.
void animation1()
for(int i=0;i<25;i++)
digitalWrite(columnPin[i],HIGH);
for(int y=0;y<5;y++)
digitalWrite(layerPin[i],LOW);
delay(1000);
digitalWrite(layerPin[i],HIGH);
delay(1000);
digitalWrite(columnPin[i],LOW);
This perform is for second animation. On this animation the Layer will activate and OFF one after the other. That is how one can create any animation you need utilizing this LED dice.
void animation2()
for(int i=0;i<5;i++)
digitalWrite(layerPin[i],LOW);
for(int y=0;y<25;y++)
digitalWrite(columnPin[i],HIGH);
delay(1000);
for(int y=0;y<25;y++)
digitalWrite(columnPin[i],LOW);
delay(1000);
digitalWrite(layerPin[i],HIGH);
That is the primary loop of this challenge. First, the animation1 will run. Then utilizing the clearPin() perform, we are going to clear all of the pins. After that animation2 will run and these three capabilities will run time and again in a loop.
void loop()
animation1();
clearPin();
animation2();