Professional Documents
Culture Documents
projecyt report
projecyt report
UNIVERSITY
BELAGAVI-590018
A Mini
Mini-Project Report on
“8*8*8 LED CUBE “
Submitted in partial fulfilment for the requirement of the award of
degree of
BACHELOR OF ENGINEERING
In
ELECTRONICS AND COMMUNICATION
ENGINEERING
By
Page | 1
2021-2022
C E RT I F I C A T E
This is to certify that the synopsis titled “8*8*8 LED CUBE”
is a bonafide wor
work being carrying out by Manish Mayank
bearing USN:1EP19EC027, Megana L bearing
USN:1EP19EC027
USN:1EP19EC027, Annu Kumari bearing USN:1EP19EC003,
USN:1EP19EC003
Ashwini K S bearing USN:1EP19EC004 in partial fulfilment for
the requirement of the award of degree of Bachelor of
Engineering in Electronics and Communication Engineering of
Visvesvaraya Technological University, Belagav
Belagavi,i, during the
academic year 2021
2021-2022.. It is certified that all the
corrections/suggestions indicated during intern
internal
al assessment
have been incorporated in this report and deposited in
departmental library. The report has been approved as it
satisfies the academic requirements prescribed by the
university.
External viva:
Name of the Examiners: Signature with date
1.
2.
Page | 2
DECLARATION
We, MANISH MAYANK bearing
USN:1EP19EC025, MEGANA L bearing
USN:1EP19EC027, ANNU KUMARI bearing
USN:1EP19EC003, ASHWINI K S bearing
USN:1EP19EC004 hereby declare that the
project titled “8*8*8 LED CUBE” is carried
out at EAST POINT COLLEGE OF
ENGINEERING AND TECHNOLOGY,
under the guidance of Dr.Anita R, Associate
Professor, department of ECE, East Point
College of Engineering and Technology,
Bangalore for partial fulfilment of the degree of
Bachelor of Engineering in Electronics and
Communication Engineering under
Visvesvaraya Technological University,
Belagavi.
Date:
Place: Bangalore
MANISH MAYANK(1EP19EC025)
MEGANA L (1EP19EC027)
Page | 3
ACKNOWLEDGEMENT
Behind every achievement lies an unfathomable sea of
gratitude to those who actuated it, without whom it
would never have come to existence. To them our
praise the word of gratitude imprinted not just on this
paper but deep in our heart.
Page | 4
ABSTRACT
Page | 5
TABLE OF CONTENTS
1. ABSTRACT 5
2. Introduction 7 -8
3. Requirements
Software Requirements 12
Explanation 16-18
5. Problem Statement 19
6. Solution Statement 20
7. Program Code
Code 21-30
Rotation 30
Animation 36-47
Page | 6
CHAPTER 1
INTRODUCTION
The goal of this paper is to be able to output and
modify the LED array fast enough to see a persistent
image. A three dimensional display is been presented
in this paper which is driven by a microcontroller. A
new form of display has been introduced in the LED
arena. Any size cube of A*A*A can be effectively
implemented which are dimensional mosaic of light
emitting diode is formed in a cube which is comprised
of light emitting diodes arranged in the dimensional
matrix.
Page | 7
This LED cube has 512 LEDs. Obviously, having a
dedicated IO port for each LED would be very
impractical. We would need a micro controller with
512 IO ports, and run 512 wires through the cube.
Instead, LED cubes rely on an optical phenomenon
called persistence of vision (POV).If we flash a led
really fast, the image will stay on our retina for a little
while after the led turns off. By flashing each layer of
the cube one after another really fast, it gives the
illusion of a 3d image, when in fact we are looking at a
series of 2d images stacked onto one another. This is
also called multiplexing. With this setup, we only need
64 (for the anodes) + 8 (for each layer) IO ports to
control the LED cube.
Page | 8
CHAPTER 2
LITERATURE SURVEY
At a glance 3D LED CUBE is an evolution from 2D
DISPLAY. Before this, 2D DISPLAY is usually used
in many electronic devices to display something. After
that, 3D takes a part on the electronic technology
world. The first era of 3D LED CUBE is built the
3x3x3 pocket led. It just use 27 led to shown some
text display or interactive design.
Page | 9
CHAPTER 3
REQUIREMENTS
HARDWARE REQUIREMENTS:
1) 74HC595 IC
2) Arduino Nano
3) LED’s
5) IC Base
6) Transistor BD241B
7) Capacitor 100uF
8) Push Button
9) PCB Board
Page | 10
Page | 11
SOFTWARE REQUIREMENTS:
• Arduino
Page | 12
CHAPTER 4
CIRCUIT DIAGRAM AND
EXPLANATION
1.CIRCUIT DIAGRAM
Page | 13
2.Wiring of led cube
3.PCB LAYER
Page | 14
4.SOLIDERING LAYER
Page | 15
EXPLANATION
A LED cube is like a LED screen, but it is special in
that it has a third dimension, making it 3D. Think of it
as many transparent low resolution displays. In normal
displays it is normal to try to stack the pixels as close as
possible in order to make it look better, but in a cube
one must be able to see trough it, and more spacing
between the pixels (actually it's voxels since it is in 3d)
is needed. The spacing is a trade-off between how easy
the layers behind it are seen, and voxel fidelity. Since it
is a lot more work making a LED cube than a LED
display, they are usually low resolution.
With this setup, there exists the need of only 64 (for the
anodes) + 8 (for each layer) IO ports to control the
LED cube. There are anodes, cathodes, columns and
layers, for this led cube.
Page | 16
are soldered together. All the anode legs in one column
are soldered together.
Page | 17
7. Each of the layers is connected to a
transistor that enables the cube to turn on
and off the flow of current through each
layer.
Page | 18
CHAPTER 5
PROBLEM STATEMENT
Improper Functioning of LED’s.
Page | 19
CHAPTER 6
SOLUTION STATEMENT
We need 512 LEDs. The first step is to test all the 512
LEDs. You can use a 3V Lithium Cell to test the individual
LED.
Page | 20
CHAPTER 7
PROGRAM CODE
#include <SPI.h>
#define XAXIS 0
#define YAXIS 1
#define ZAXIS 2
#define POS_X 0
#define NEG_X 1
#define POS_Z 2
#define NEG_Z 3
#define POS_Y 4
#define NEG_Y 5
#define BUTTON_PIN 8
#define RED_LED 5
#define GREEN_LED 7
#define TOTAL_EFFECTS 8
#define RAIN 0
#define PLANE_BOING 1
#define SEND_VOXELS 2
#define WOOP_WOOP 3
#define CUBE_JUMP 4
#define GLOW 5
#define TEXT 6
#define LIT 7
#define RAIN_TIME 260
#define PLANE_BOING_TIME 220
#define SEND_VOXELS_TIME 140
#define WOOP_WOOP_TIME 350
#define CUBE_JUMP_TIME 200
#define GLOW_TIME 8
#define TEXT_TIME 300
#define CLOCK_TIME 500
uint8_t characters[10][8] =
{
{0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C},
//0
Page | 21
{0x10, 0x18, 0x14, 0x10, 0x10, 0x10, 0x10, 0x3C},
//1
{0x3C, 0x42, 0x40, 0x40, 0x3C, 0x02, 0x02, 0x7E},
//2
{0x3C, 0x40, 0x40, 0x3C, 0x40, 0x40, 0x42, 0x3C},
//3
{0x22, 0x22, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x20},
//4
{0x7E, 0x02, 0x02, 0x3E, 0x40, 0x40, 0x42, 0x3C},
//5
{0x3C, 0x02, 0x02, 0x3E, 0x42, 0x42, 0x42, 0x3C},
//6
{0x3C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40},
//7
{0x3C, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x42, 0x3C},
//8
{0x3C, 0x42, 0x42, 0x42, 0x3C, 0x40, 0x40, 0x3C},
//9
}
;
uint8_t cube[8][8];
uint8_t currentEffect;
uint16_t timer; uint64_t randomTimer;
bool loading;
void setup() { loading = true; randomTimer = 0;
currentEffect = RAIN;
SPI.begin();
SPI.beginTransaction(SPISettings(8000000,
MSBFIRST, SPI_MODE0));
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
randomSeed(analogRead(0));
digitalWrite(GREEN_LED, HIGH); } void loop() {
randomTimer++;
if (digitalRead(BUTTON_PIN) == LOW)
{
clearCube();
loading = true;
timer = 0;
currentEffect++;
if (currentEffect == TOTAL_EFFECTS) {
currentEffect = 0;
Page | 22
}
randomSeed(randomTimer); randomTimer = 0;
digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED, LOW);
delay(500);
digitalWrite(RED_LED, LOW);
digitalWrite(GREEN_LED, HIGH);
}
switch (currentEffect)
{
case RAIN: rain();
break;
case PLANE_BOING: planeBoing();
break;
case SEND_VOXELS: sendVoxels();
break;
case WOOP_WOOP: woopWoop();
break;
case CUBE_JUMP: cubeJump();
break; case GLOW: glow();
break;
case TEXT: text("0123456789", 10);
break; case LIT: lit();
break; default: rain();
}
renderCube();
}
void renderCube()
{
for (uint8_t i = 0; i < 8; i++)
{
digitalWrite(SS, LOW);
SPI.transfer(0x01 << i);
for (uint8_t j = 0; j < 8; j++)
{
SPI.transfer(cube[i][j]); } digitalWrite(SS, HIGH);
}
}
uint8_t planePosition = 0;
uint8_t planeDirection = 0;
bool looped = false;
void planeBoing()
{
Page | 23
if (loading)
{
clearCube();
uint8_t axis = random(0, 3);
planePosition = random(0, 2) * 7;
setPlane(axis, planePosition);
if (axis == XAXIS)
{
if (planePosition == 0)
{
planeDirection = POS_X;
}
else
{
planeDirection = NEG_X;
}
}
else if (axis == YAXIS)
{
if (planePosition == 0)
{
planeDirection = POS_Y;
}
else
{
planeDirection = NEG_Y;
}
}
else if (axis == ZAXIS)
{
if (planePosition == 0)
{
planeDirection = POS_Z;
}
Else
{
planeDirection = NEG_Z;
}
}
timer = 0;
looped = false; loading = false;
}
timer++;
Page | 24
if (timer > PLANE_BOING_TIME)
{
timer = 0;
shift(planeDirection);
if (planeDirection % 2 == 0)
{
planePosition++;
if (planePosition == 7)
{
if (looped)
{
loading = true;
}
Else
{
planeDirection++;
looped = true;
}
}
}
Else
{
planePosition--;
if (planePosition == 0)
{
if (looped)
{
loading = true;
}
else
{
planeDirection--;
looped = true;
}
}
}
}
}
void lit()
{
if (loading)
{
clearCube();
Page | 25
for(uint8_t i=0; i<8; i++)
{
for(uint8_t j=0; j<8; j++)
{
cube[i][j] = 0xFF;
}
}
loading = false;
}
}
void setVoxel(uint8_t x, uint8_t y, uint8_t z)
{
cube[7 - y][7 - z] |= (0x01 << x);
}
void clearVoxel(uint8_t x, uint8_t y, uint8_t z)
{
cube[7 - y][7 - z] ^= (0x01 << x);
}
bool getVoxel(uint8_t x, uint8_t y, uint8_t z)
{
return (cube[7 - y][7 - z] & (0x01 << x)) == (0x01 <<
x);
}
void setPlane(uint8_t axis, uint8_t i)
{
for (uint8_t j = 0; j < 8; j++)
{
for (uint8_t k = 0; k < 8; k++)
{
if (axis == XAXIS)
{
setVoxel(i, j, k);
}
else if (axis == YAXIS)
{
setVoxel(j, i, k);
}
else if (axis == ZAXIS)
{
setVoxel(j, k, i);
}
}
}
Page | 26
}
void shift(uint8_t dir)
{
if (dir == POS_X)
{
for (uint8_t y = 0; y < 8; y++)
{
for (uint8_t z = 0; z < 8; z++)
{
cube[y][z] = cube[y][z] << 1;
}
}
}
else if (dir == NEG_X)
{
for (uint8_t y = 0; y < 8; y++)
{
for (uint8_t z = 0; z < 8; z++)
{
cube[y][z] = cube[y][z] >> 1;
}
}
}
else if (dir == POS_Y)
{
for (uint8_t y = 1; y < 8; y++)
{
for (uint8_t z = 0; z < 8; z++)
{
cube[y - 1][z] = cube[y][z];
}
}
for (uint8_t i = 0; i < 8; i++)
{
cube[7][i] = 0;
}
}
else if (dir == NEG_Y)
{
for (uint8_t y = 7; y > 0; y--)
{
for (uint8_t z = 0; z < 8; z++)
{
Page | 27
cube[y][z] = cube[y - 1][z];
}
}
for (uint8_t i = 0; i < 8; i++)
{
cube[0][i] = 0;
}
}
else if (dir == POS_Z)
{
for (uint8_t y = 0; y < 8; y++)
{
for (uint8_t z = 1; z < 8; z++)
{
cube[y][z - 1] = cube[y][z];
}
}
for (uint8_t i = 0; i < 8; i++)
{
cube[0][i] = 0;
}
}
else if (dir == POS_Z)
{
for (uint8_t y = 0; y < 8; y++)
{
for (uint8_t z = 1; z < 8; z++)
{
cube[y][z - 1] = cube[y][z];
}
}
for (uint8_t i = 0; i < 8; i++)
{
cube[i][7] = 0;
}
}
else if (dir == NEG_Z)
{
for (uint8_t y = 0; y < 8; y++)
{
for (uint8_t z = 7; z > 0; z--)
{
cube[y][z] = cube[y][z - 1];
Page | 28
}
}
for (uint8_t i = 0; i < 8; i++)
{
cube[i][0] = 0;
}
}
}
void drawCube(uint8_t x, uint8_t y, uint8_t z, uint8_t
s)
{
for (uint8_t i = 0; i < s; i++)
{
setVoxel(x, y + i, z);
setVoxel(x + i, y, z);
setVoxel(x, y, z + i);
setVoxel(x + s - 1, y + i, z + s - 1);
setVoxel(x + i, y + s - 1, z + s - 1);
setVoxel(x + s - 1, y + s - 1, z + i);
setVoxel(x + s - 1, y + i, z);
setVoxel(x, y + i, z + s - 1);
setVoxel(x + i, y + s - 1, z);
setVoxel(x + i, y, z + s - 1);
setVoxel(x + s - 1, y, z + i);
setVoxel(x, y + s - 1, z + i);
}
}
void lightCube()
{
for (uint8_t i = 0; i < 8; i++)
{
for (uint8_t j = 0; j < 8; j++)
{
cube[i][j] = 0xFF;
}
}
}
void clearCube()
{
for (uint8_t i = 0; i < 8; i++)
{
for (uint8_t j = 0; j < 8; j++)
{
Page | 29
cube[i][j] = 0;
}
}
}
ROTATION
#ifndef ROTATION_H
#define ROTATION_H
#include <stdlib.h>
#include <avr/io.h>
#include <inttypes.h>
#define CL_LOOP_DELAY 30 //was 6
void rotate_90_auto ( uint8_t cycle );
void rotate_15_deg( void );
void rotate_30_deg( void );
void rotate_45_deg( void );
void rotate_60_deg( void );
void rotate_75_deg( void );
void rotate_90_deg( void );
#endif
SOURCE FILES
#include "ledcube.h"
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
#include "ab.h"
void cube_char( char ch, uint8_t z )
{
switch (ch)
{
case '0':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
cube[1][1] |= z;
cube[1][5] |= z;
cube[2][1] |= z;
cube[2][2] |= z;
cube[2][5] |= z;
Page | 30
cube[3][1] |= z;
cube[3][3] |= z;
cube[3][5] |= z;
cube[4][1] |= z;
cube[4][4] |= z;
cube[4][5] |= z;
cube[5][1] |= z;
cube[5][5] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
break;
case '1':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
cube[1][3] |= z;
cube[2][3] |= z;
cube[3][3] |= z;
cube[4][3] |= z;
cube[5][2] |= z;
cube[5][3] |= z;
cube[6][3] |= z;
break;
case '2':
cube[0][1] |= z;
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
cube[0][5] |= z;
cube[1][2] |= z;
cube[2][3] |= z;
cube[3][4] |= z;
cube[4][5] |= z;
cube[5][1] |= z;
cube[5][5] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
break;
case '3':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
Page | 31
cube[1][1] |= z;
cube[1][5] |= z;
cube[2][5] |= z;
cube[3][4] |= z;
cube[4][3] |= z;
cube[5][4] |= z;
cube[6][1] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
cube[6][5] |= z;
break;
case '4':
cube[0][4] |= z;
cube[1][4] |= z;
cube[2][1] |= z;
cube[2][2] |= z;
cube[2][3] |= z;
cube[2][4] |= z;
cube[2][5] |= z;
cube[3][1] |= z;
cube[3][4] |= z;
cube[4][2] |= z;
cube[4][4] |= z;
cube[5][3] |= z;
cube[5][4] |= z;
cube[6][4] |= z;
break;
case '5':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
cube[1][1] |= z;
cube[1][5] |= z;
cube[2][5] |= z;
cube[3][5] |= z;
cube[4][1] |= z;
cube[4][2] |= z;
cube[4][3] |= z;
cube[4][4] |= z;
cube[5][1] |= z;
cube[6][1] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
Page | 32
cube[6][4] |= z;
cube[6][5] |= z;
break;
case '6':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
cube[1][1] |= z;
cube[1][5] |= z;
cube[2][1] |= z;
cube[2][5] |= z;
cube[3][1] |= z;
cube[3][2] |= z;
cube[3][3] |= z;
cube[3][4] |= z;
cube[4][1] |= z;
cube[5][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
break;
case '7':
cube[0][2] |= z;
cube[1][2] |= z;
cube[2][2] |= z;
cube[3][3] |= z;
cube[4][4] |= z;
cube[5][5] |= z;
cube[6][1] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
cube[6][5] |= z;
break;
case '8':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][4] |= z;
cube[1][1] |= z;
cube[1][5] |= z;
cube[2][1] |= z;
cube[2][5] |= z;
cube[3][2] |= z;
cube[3][3] |= z;
cube[3][4] |= z;
Page | 33
cube[4][1] |= z;
cube[4][5] |= z;
cube[5][1] |= z;
cube[5][5] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
break;
case '9':
cube[0][2] |= z;
cube[0][3] |= z;
cube[1][4] |= z;
cube[2][5] |= z;
cube[3][2] |= z;
cube[3][3] |= z;
cube[3][4] |= z;
cube[3][5] |= z;
cube[4][1] |= z;
cube[4][5] |= z;
cube[5][1] |= z;
cube[5][5] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
break;
case '!':
cube[0][3] |= z;
cube[3][3] |= z;
cube[4][3] |= z;
cube[5][2] |= z;
cube[5][3] |= z;
cube[5][4] |= z;
cube[6][1] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
cube[6][5] |= z;
break;
case ':':
cube[1][2] |= z;
cube[1][3] |= z;
cube[2][2] |= z;
cube[2][3] |= z;
cube[4][2] |= z;
Page | 34
cube[4][3] |= z;
cube[5][2] |= z;
cube[5][3] |= z;
break;
case '.':
cube[1][2] |= z;
cube[1][3] |= z;
cube[2][2] |= z;
cube[2][3] |= z;
break;
case '?':
cube[0][3] |= z;
cube[2][3] |= z;
cube[3][4] |= z;
cube[4][5] |= z;
cube[5][1] |= z;
cube[5][5] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
cube[6][4] |= z;
break;
case '&':
cube[0][2] |= z;
cube[0][3] |= z;
cube[0][5] |= z;
cube[1][1] |= z;
cube[1][4] |= z;
cube[2][1] |= z;
cube[2][3] |= z;
cube[2][5] |= z;
cube[3][2] |= z;
cube[4][1] |= z;
cube[4][3] |= z;
cube[5][1] |= z;
cube[5][4] |= z;
cube[6][2] |= z;
cube[6][3] |= z;
break;
default:
break;
}
}
ANIMATIONS
Page | 35
#include "ab.h"
#include "ledcube.h"
#include "animations.h"
#include <stdlib.h>
#include <avr/io.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <math.h>
#include "rotation.h"
#include "translation.h"
void cube_stripes( void )
{
cube_clear();
for (uint8_t i = 0; i < 8; i++) {
cube[0][0] |= ( 1 << i );
cube[1][7] |= ( 1 << (7-i) );
cube[2][0] |= ( 1 << i );
cube[3][7] |= ( 1 << (7-i) );
cube[4][0] |= ( 1 << i );
cube[5][7] |= ( 1 << (7-i) );
cube[6][0] |= ( 1 << i );
cube[7][7] |= ( 1 << (7-i) );
cube_show_loop(STRIPES_DELAY);
}
for (uint8_t j = 1; j < 8; j++) {
cube_clear();
for (uint8_t i = 0; i < 8; i++) {
cube[0][j] |= ( 1 << i );
cube[1][7-j] |= ( 1 << i );
cube[2][j] |= ( 1 << i );
cube[3][7-j] |= ( 1 << i );
cube[4][j] |= ( 1 << i );
cube[5][7-j] |= ( 1 << i );
cube[6][j] |= ( 1 << i )
return 1;
}
uint8_t cube2_move_x_rev( char cube2[4][4], uint8_t
y, uint8_t x, uint8_t z )
{
if (!(cube2[y][x-1] & (1 << z))){
cube2[y][x] &= ~(1 << z);
cube2[y][x-1] |= (1 << z);
Page | 36
return 0;
}
return 1;
}
uint8_t cube2_move_z_fwd( char cube2[4][4], uint8_t
y, uint8_t x, uint8_t z )
{
if (!(cube2[y][x] & (1 << (z+1)))){
cube2[y][x] &= ~(1 << z);
cube2[y][x] |= (1 << (z+1));
return 0;
}
return 1;
}
uint8_t cube2_move_z_rev( char cube2[4][4], uint8_t
y, uint8_t x, uint8_t z )
{
if (!(cube2[y][x] & (1 << (z-1)))){
cube2[y][x] &= ~(1 << z);
cube2[y][x] |= (1 << (z-1));
return 0;
}
return 1;
}
void cube_2_auto_show( char cube2[4][4] )
{
for (uint8_t layer = 0; layer < 4; layer++){
cube_clear_layer(layer*2+1);
cube_clear_layer(layer*2);
for (uint8_t x = 0; x < 4; x++){
for (uint8_t z = 0; z < 4; z++){
if (cube2[layer][x] & ( 1 << z)) {
cube[layer*2][x*2] |= (1 << (z*2));
cube[layer*2][x*2] |= (1 << (z*2+1));
cube[layer*2][x*2+1] |= (1 << (z*2));
cube[layer*2][x*2+1] |= (1 << (z*2+1));
cube[layer*2+1][x*2] |= (1 << (z*2));
cube[layer*2+1][x*2] |= (1 << (z*2+1));
cube[layer*2+1][x*2+1] |= (1 << (z*2));
cube[layer*2+1][x*2+1] |= (1 << (z*2+1));
}
}
}
}
Page | 37
cube_show_loop(CUBE_AUTO_DELAY);
}
void cubes_2( void )
{
cube_clear();
for (uint8_t i = 0; i < 8; i++ ){
cube[0][i] = 0xFF;
cube[1][i] = 0xFF;
}
cube_show_loop(CUBES2_DELAY);
for (uint8_t i = 0; i < 6; i++) {
move_y_fwd(2,2,3,3);
move_y_fwd(2,6,3,7);
move_y_fwd(6,2,7,3);
move_y_fwd(6,6,7,7);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 4; i++) {
move_y_fwd(0,0,1,1);
move_y_fwd(0,4,1,5);
move_y_fwd(4,0,5,1);
move_y_fwd(4,4,5,5);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 2; i++) {
move_y_fwd(2,0,3,1);
move_y_fwd(6,0,7,1);
move_y_fwd(2,4,3,5);
move_y_fwd(6,4,7,5);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 4; i++) {
move_y_rev(6,2,7,3);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 2; i++) {
move_y_rev(4,0,5,1);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 6; i++) {
move_z_fwd(2,4,3,5);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 2; i++) {
Page | 38
move_y_rev(2,0,3,1);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 6; i++) {
move_z_fwd(0,2,1,3);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 4; i++) {
move_y_fwd(0,2,1,3);
cube_show_loop(CUBES2_DELAY);
}
for (uint8_t i = 0; i < 2; i++) {
move_x_fwd(2,4,3,5);
cube_show_loop(CUBES2_DELAY);
}
cube_show_loop(CUBES2_DELAY*10);
}
/* cubemoving 4x4 */
void cubes_4( void )
{
cube_clear();
for (uint8_t layer = 0; layer <= 3; layer++){
cube[layer][0] = 0b00001111;
cube[layer][1] = 0b00001111;
cube[layer][2] = 0b00001111;
cube[layer][3] = 0b00001111;
}
for (uint8_t layer = 4; layer <= 7; layer++){
cube[layer][4] = 0b11111111;
cube[layer][5] = 0b11111111;
cube[layer][6] = 0b11111111;
cube[layer][7] = 0b11111111;
}
cube_show_loop(CUBES4_DELAY);
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_y_rev(4,0,7,3);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_z_fwd(0,0,3,3);
cube_show_loop(CUBES4_DELAY);
}
Page | 39
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_y_fwd(0,4,3,7);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_y_rev(4,4,7,7);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_x_rev(0,0,3,3);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_z_rev(4,0,7,3);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_z_fwd(4,0,7,3);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_y_fwd(4,4,7,7);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_x_fwd(0,0,3,3);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_y_fwd(4,0,7,3);
cube_show_loop(CUBES4_DELAY);
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_y_rev(0,4,3,7);
cube_show_loop(CUBES4_DELAY);
Page | 40
}
for (uint8_t fourtimes = 0; fourtimes <= 3;
fourtimes++){
move_z_rev(0,0,3,3);
cube_show_loop(CUBES4_DELAY);
}
}
/* shrinking outline */
void outline_shrink( void )
{
cube_clear();
for (uint8_t i = 1; i < 7; i++ ){
cube[i][0] = 0b10000001;
cube[i][7] = 0b10000001;
}
for (uint8_t i = 1; i < 7; i++){
cube[0][i] = 0b10000001;
cube[7][i] = 0b10000001;
}
cube[0][0] = 0xFF;
cube[7][0] = 0xFF;
cube[0][7] = 0xFF;
cube[7][7] = 0xFF;
cube_show_loop(OUT_SHRINK_DELAY);
for (uint8_t i = 2; i < 6; i++ ){
cube[i][1] = 0b01000010;
cube[i][6] = 0b01000010;
}
for (uint8_t i = 2; i < 6; i++){
cube[1][i] = 0b01000010;
cube[6][i] = 0b01000010;
}
cube[1][1] = 0b01111110;
cube[6][1] = 0b01111110;
cube[1][6] = 0b01111110;
cube[6][6] = 0b01111110;
cube_show_loop(OUT_SHRINK_DELAY);
for (uint8_t i = 3; i < 5; i++ ){
cube[i][2] = 0b00100100;
cube[i][5] = 0b00100100;
}
for (uint8_t i = 3; i < 5; i++){
cube[2][i] = 0b00100100;
cube[5][i] = 0b00100100;
Page | 41
}
cube[2][2] = 0b00111100;
cube[5][2] = 0b00111100;
cube[2][5] = 0b00111100;
cube[5][5] = 0b00111100;
cube_show_loop(OUT_SHRINK_DELAY);
cube[3][3] = 0b00011000;
cube[4][3] = 0b00011000;
cube[3][4] = 0b00011000;
cube[4][4] = 0b00011000;
cube_show_loop(10*OUT_SHRINK_DELAY);
}
void cube_explosion( void )
{
uint8_t led_state = 0b00011000;
for (uint8_t i = 0; i <= 4; i++){
for (uint8_t j = 3; j <= (i+3); j++) {
for (uint8_t k = 3; k <= (i+3); k++){
cube[j][7-k] = led_state;
cube[j][k] = led_state;
cube[7-j][7-k] = led_state;
cube[7-j][k] = led_state;
}
}
cube_show_loop(EXPLOSION_DELAY*(2*i+1));
led_state |= (1 << (3-i)) | (1 << (4+i));
}
cube_show_loop(EXPLOSION_DELAY);
for (uint8_t i = 0; i <= 4; i++){
led_state &= ~((1 << (3-i)) | (1 << (4+i)));
for (uint8_t j = 3; j <= (i+3); j++) {
for (uint8_t k = 3; k <= (i+3); k++){
cube[j][7-k] = led_state;
cube[j][k] = led_state;
cube[7-j][7-k] = led_state;
cube[7-j][k] = led_state;
}
}
cube_show_loop(EXPLOSION_DELAY*(2*i+1));
}
cube_show_loop(EXPLOSION_DELAY);
}
/* wipe */
void cube_wipe( void )
Page | 42
{
cube_test_y();
cube_show_loop(SWIPE_DELAY);
for (uint8_t layer = 0; layer < 7; layer++){
for (uint8_t i = 0; i < 8; i++){
cube[layer][i] = 0;
cube[layer+1][i] = 0xFF;
}
cube_show_loop(SWIPE_DELAY);
}
for (uint8_t layer = 0; layer < 7; layer++){
move_y_rev(0,0,7,7);
cube_show_loop(SWIPE_DELAY);
}
}
void cube_string_belt( char *string )
{
char cube_belt[25];
for (uint8_t i = 0; i < 25; i++) { cube_belt[i] = 0; }
string++;
string++;
while(*string){
set_char_to_belt(*string, cube_belt);
for (uint8_t i = 0; i < 6; i++){
show_belt(cube_belt);
move_belt_left(cube_belt);
}
string++;
}
/* move the rest out */
for (uint8_t i = 0; i < 18; i++){
show_belt(cube_belt);
move_belt_left(cube_belt);
}
}
void move_belt_left( char *belt )
{
for (uint8_t i = 25; i > 1; i--){
belt[i-1] = belt[i-2];
}
belt[0] = 0;
}
void set_char_to_belt( char character, char *belt )
{
Page | 43
cube_clear();
cli();
PORTC = 0x00;
cube_char(character, 1);
for (uint8_t layer = 0; layer < 8; layer++) {
for (uint8_t i = 1; i < 6; i++){
if (cube[layer][i] & 0x01)
belt[5-i] |= (1 << layer);
}
}
cube_clear();
sei();
}
void show_belt( char *belt )
{
cube_clear();
/* right side */
for (uint8_t i = 5; i <= 11; i++){
for (uint8_t j = 0; j < 8; j++){
if (belt[i] & (1 << j))
cube[j][7] |= (1 << (12-i));
}
}
/* front side */
for (uint8_t i = 12; i <= 17; i++){
for (uint8_t j = 0; j < 8; j++){
if (belt[i] & (1 << j))
cube[j][18-i] |= (1 << 0);
}
}
/* left side */
for (uint8_t i = 18; i <= 24; i++){
for (uint8_t j = 0; j < 8; j++){
if (belt[i] & (1 << j))
cube[j][0] |= (1 << (i-17));
}
}
cube_show_loop(SHOW_BELT_DELAY);
}
/* 2 fixed chars rotating */
void cube_fixed_string( void )
{
cube_clear();
_delay_ms(600);
Page | 44
cube_clear();
_delay_ms(600);
cube_char('3', 2);
_delay_ms(600);
rotate_90_deg();
_delay_ms(600);
rotate_90_deg();
_delay_ms(600);
cube_char('d', 2);
_delay_ms(600);
rotate_90_deg();
_delay_ms(600);
rotate_90_auto(8);
_delay_ms(600);
}
/* back to front moving */
void cube_string_to_front( char *string )
{
while(*string) {
_delay_ms(200);
for (uint8_t i = 8; i > 0; i--){
_delay_ms(200);
cube_clear();
_delay_ms(200);
cube_char(*string, (1 << (i-1)));
_delay_ms(300);
cube_show_loop(3);
_delay_ms(300);
}
string++;
_delay_ms(300);
}
}
void cube_string( char *string )
{
while(*string){
cube_clear();
cli();
PORTC = 0x00;
cube_char(*string, 16);
string++;
rotate_90_deg();
rotate_90_deg();
rotate_90_deg();
Page | 45
move_x_rev(1,0,6,7);
move_x_rev(1,0,6,7);
move_x_rev(1,0,6,7);
sei();
cube_show_loop(CUBE_STRING_DELAY);
move_x_fwd(1,0,6,7);
cube_show_loop(CUBE_STRING_DELAY);
move_x_fwd(1,0,6,7);
cube_show_loop(CUBE_STRING_DELAY);
move_x_fwd(1,0,6,7);
cube_show_loop(CUBE_STRING_DELAY);
rotate_90_auto(1);
move_z_rev(0,0,7,7);
cube_show_loop(CUBE_STRING_DELAY);
move_z_rev(0,0,7,7);
cube_show_loop(CUBE_STRING_DELAY);
move_z_rev(0,0,7,7);
cube_show_loop(CUBE_STRING_DELAY);
move_z_rev(0,0,7,7);
cube_show_loop(CUBE_STRING_DELAY);
cube_flash(5);
cube_explosion();
}
cube_explosion();
cube_explosion();
}
void cube_outline( void )
{
cube_clear();
cube_show_loop(OUTLINE_DELAY);
for (uint8_t i = 0; i < 8; i++) {
cube[0][0] |= (1 << i);
cube[i][0] |= 1;
cube[0][i] |= 1;
cube_show_loop(OUTLINE_DELAY);
}
Page | 46
cube_show_loop(OUTLINE_DELAY);
}
for (uint8_t i = 1; i < 8; i++) {
cube[7][i] |= 128;
cube[7][7] |= (1 << i);
cube[i][7] |= 128;
cube_show_loop(OUTLINE_DELAY);
}
cube_show_loop(20);
/* shrink */
cube_clear();
cube[1][1] = 0b01111110;
cube[1][6] = 0b01111110;
cube[6][1] = 0b01111110;
cube[6][6] = 0b01111110;
for (uint8_t i=2; i< 6; i++) {
cube[1][i] = 0b01000010;
cube[6][i] = 0b01000010;
cube[i][1] = 0b01000010;
cube[i][6] = 0b01000010;
}
cube_show_loop(30);
rotate_90_auto( 8 );
}
void cube_stars( void )
{
for (uint8_t j = 1; j < 30; j++){
for (uint8_t loops = 0; loops < 18; loops++){
cube_clear();
for (uint8_t i = 0; i< j; i++){
uint8_t randx = (uint8_t)rand()%8;
uint8_t randy = (uint8_t)rand()%8;
uint8_t randz = (uint8_t)rand()%8;
cube[randy][randx] = (1 << randz);
}
// cube[randy][randx] &= ~(1 << randz);
cube_show_loop(STARS_DELAY);
}
}
}
Page | 47
CHAPTER 8
Page | 48
Page | 49
Page | 50
Page | 51
CHAPTER 9
ADVANTAGES AND
DISADVANTAGES
ADVANTAGES:
a. Energy Efficient
b. No warm up Period
c. Not Affected by Cold Temperatures
d. Directional
e. Environmental friendly
f. Controllable
DISADVANTAGES:
a. Blue Hazzard
b. Light Quality
c. Temperature Dependance
d. Blue Pollution
e. Voltage Sensitivity
Page | 52
CHAPTER 10
Page | 53
CHAPTER 11
Page | 54
CHAPTER 12
REFERENCES
[1] Aruna pant et al., (2016) “Three Dimensional
Array, 512 LEDs, LED Cube”. Published in
International Journal of Modern Trends in
Engineering and Science, ISSN no: 2348-3121.
Page | 55
Page | 56