
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:

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.
Figure 3: AVR ATMega16 pin diagram

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.

Figure 5: Representation image of the LED cube

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 | ![]() |
