Cubo LED 3D (4x4x4)

3D LED Cube (4x4x4)

The basic objective is to create a 3D LED cube capable of showing pre-defined animations.
A typical 3D LED display is a collection of LEDs, somehow connected and arranged in a 3D pattern and controlled so that the LEDs can be turned on and off in a controlled manner, thus creating interesting and pleasing light patterns. Probably the most common type of 3D LED display is the LED cube. The 3D array is constructed by soldering the legs of the LEDs directly to each other or by constructing an array of wires that form a structure to which the LEDs are connected. There are also many different ways to control a 3D LED display that vary in complexity, the simplest is probably a single microcontroller, with more complicated methods using special LED driver ICs or even direct PC control.

Protótipo de cubo LED controlado por AVR ATMega16

Figure 1: LED cube prototype controlled by AVR ATMega16

Working:

The LED cube has 64 LEDs (4x4x4). Each LED is dedicated to an IO port on a microcontroller. The LED cube relies on an optical phenomenon called Persistence of Vision. If you blink an LED too quickly, it will remain on your retina for some time even after the LED is turned off. By flashing each layer of the cube very quickly, one after the other, it gives the feeling of 3D. With this configuration we will only need 16 (anode) + 4 (layers) IO ports to control each LED. The LED has two legs, one positive and one negative. The positive end is connected to the pillars of the LED cube which acts as the anode while the negative is connected to the layer. Thus, to turn on a given LED we have to supply current to the corresponding pillar and ground the layer.

Block Diagram:

Diagrama de blocos do cubo LED controlado por AVR ATMega16

Figure 2: Block diagram of the LED cube controlled by AVR ATMega16

Power supply: We use 5V regulated power supply using 7805 voltage regulator and 9V battery, for our project.

Microcontroller:

It is the heart of the project that allows you to control the LED Cube by generating predefined animations. The input/output ports of the microcontroller are used for this purpose. We use Atmega 16 microcontroller in our project.

Diagrama de pinos do AVR ATMega16

Figure 3: AVR ATMega16 pin diagram

Protótipo de circuito de controle de cubo LED baseado em AVR ATMega16

Figure 4: Prototype LED cube control circuit based on AVR ATMega16

LED Cube:

Connecting the LED cube is done as follows. All the anodes of a layer are connected like a pillar of the cube and the cathodes are short-circuited around the layer. Thus, we have 4 cathode pins in 4 cube layers and 16 cathode pins as cube pillars.

Imagem de representação do cubo de LED

Figure 5: Representation image of the LED cube

Protótipo de LED Cube controlado por AVR ATMega16

Figure 6: Cube LED prototype controlled by AVR ATMega16

The circuit:

{Check the circuit diagram tab to see the complete circuit of 3D LED Cube (4x4x4)}

Schedule:

Programming is done in Eclipse IDE in Embedded C. The code is attached to this document. I created 4 animation patterns in each 'for loop'.

Project source code

###


#include

#include

main void

{

DDRA=0xff;

DDRB=0xff;

DDRD=0xff;

internal l,j,k,l,m;

while (1)

{

for (l=0;l<6;l++)

{

PORTD=~1;

PORT=0b00010001;

PORTB=0b00010001;

_delay_ms (200);

PORTD=~2;

PORT=0b00010001;

PORTB=0b00010001;

_delay_ms (200);

PORTD=~4;

PORT=0b00010001;

PORTB=0b00010001;

_delay_ms (200);

PORTD=~8;

PORT=0b00010001;

PORTB=0b00010001;

_delay_ms (200);

PORTD=~4;

PORT=0b00100010;

PORTB=0b00100010;

_delay_ms (200);

PORTD=~2;

PORT=0b01000100;

PORTB=0b01000100;

_delay_ms (200);

PORTD=~1;

PORT=0b10001000;

PORTB=0b10001000;

_delay_ms (200);

PORTD=~2;

PORT=0b10001000;

PORTB=0b10001000;

_delay_ms (200);

PORTD=~4;

PORT=0b10001000;

PORTB=0b10001000;

_delay_ms (200);

PORTD=~8;

PORT=0b10001000;

PORTB=0b10001000;

_delay_ms (200);

PORTD=~4;

PORT=0b01000100;

PORTB=0b01000100;

_delay_ms (200);

PORTD=~2;

PORT=0b00100010;

PORTB=0b00100010;

_delay_ms (200);

}

for (j=0;j<6;j++)

{

PORTD=~8;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

PORTD=~4;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

PORTD=~2;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

PORTD=~1;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

}

for (k=0;k<6;k++)

{

PORTD=~1;

PORT=~0b10011111;

PORTB=~0b11111001;

_delay_ms (200);

PORTD=~2;

PORT=~0b10011111;

PORTB=~0b11111001;

_delay_ms (200);

PORTD=~4;

PORT=~0b10011111;

PORTB=~0b11111001;

_delay_ms (200);

PORTD=~8;

PORT=~0b10011111;

PORTB=~0b11111001;

_delay_ms (200);

PORTD=~8;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

PORTD=~4;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

PORTD=~2;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

PORTD=~1;

PORT=0b10011111;

PORTB=0b11111001;

_delay_ms (200);

}

for (l=0;l<6;l++)

{

PORTD=~1;

PORT=1; _delay_ms (100);

PORTD=~2;

PORT=0b00100000; _delay_ms (100);PORT=0;

PORTD=~4;

PORTB=0b00000100; _delay_ms (100);

PORTD=~8;

PORTB=0b10000000; _delay_ms (100);

PORTD=~4;

PORTB=0b00001000; _delay_ms (100);PORTB=0;

PORTD=~2;

PORT=0b10000000; _delay_ms (100);

PORTD=~1;

PORT=0b00001000; _delay_ms (100);

PORTD=~2;

PORT=0b01000000; _delay_ms (100);PORT=0;

PORTD=~4;

PORTB=0b00000010; _delay_ms (100);

PORTD=~8;

PORTB=0b00010000; _delay_ms (100);

PORTD=~4;

PORTB=0b00000001; _delay_ms (100);PORTB=0;

PORTD=~2;

PORT=0b00010000; _delay_ms (100);

}

for (m=0;m<10000;m++)

{

PORTD=~1;

PORT=0b10011111;

PORTB=0b11111001;

_delay_us (100);

PORTD=~2;

PORT=0b00001001;

PORTB=0b10010000;

_delay_us (100);

PORTD=~4;

PORT=0b00001001;

PORTB=0b10010000;

_delay_us (100);

PORTD=~8;

PORT=0b10011111;

PORTB=0b11111001;

_delay_us (100);

}

}

}

###

Circuit diagrams

Circuit Diagram-AVR-ATMega16-LED-Cube

Back to the blog

Leave a comment

Comments need to be approved before publication.