Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

CEP

University of Engineering and Technology


Department of Electrical Engineering
COMPLEX ENGINEERING PROBLEM

LED CUBE
MICROPROCESSOR SYSTEMS

Submitted To: Eng. Osama Bin Naeem

Submitted By: GROUP # 01

Bushra Rabab 2020-EE-634 (L)


Sarah 2020-EE-611
Maania Jabbar 2020-EE-626
Farah Khalid 2020-EE-639
1. ABSTRACT EE-273L
— MICROPROCESSOR
Now a days we cannot imagine world without technology. By SYSTEMS
developing technology, microcontroller is very important part for the
performance of any type programming through electronics.
A three-dimensional structure,cube, made up of 4 levels, each with
4x4=16 light emitting diodes (LEDs). The LEDs are arranged in a grid
pattern, with each level stacked on top of the previous one. The cube
can be programmed to light up the LEDs in various patterns and
sequences. A microcontroller is required to control different effects or
illusions created by cube, STM32F407 will be used for the practical LED CUBE
implementation of our work. LED cubes applications involves
decorative displays, artistic projects, educational demonstrations, and
more.

2. INTRODUCTION
__
This project is based on microcontroller for the lightning scheme of led
cube. An LED cube is a three-dimensional arrangement of light emitting
THE ULTIMATE
diodes (LEDs) that can be used to create a variety of visual effects. The
LEDs are mounted on the surface of a cube-shaped frame, and can be DISPLAY OF
controlled to light up in a variety of patterns and sequences. LED cubes CREATIVITY AND
can be used for a variety of purposes, including decoration, art TECHNOLOGY:
installations, and as a tool for education and experimentation. THE LED CUBE!
THIS DYNAMIC
LED cubes can be made in a variety of sizes, ranging from small cubes
with just a few LEDs to large cubes with hundreds of LEDs. They can STRUCTURE IS
be powered by a variety of methods, including batteries, AC power, or MADE UP OF 16
even solar panels. The LEDs can be controlled using a microcontroller LEDS THAT CAN
or other electronic control device, which allows the user to program the BE PROGRAMMED
LED cube to display a wide range of patterns and sequences.
TO LIGHT UP IN
LED cubes can be used as a tool for teaching about electronics and AN ENDLESS
programming. They provide a hands-on way for students to learn about VARIETY OF
concepts such as microcontrollers, LED control, and programming PATTERNS AND
logic. LED cubes provide a platform for experimentation and SEQUENCES.
exploration. They can be used to try out different programming
techniques, test out new ideas, or simply play around with light and
color.
1
3. METHADOLOGY
Following are steps that were taken in making of LED cube:

3.1 Materials Required:


 64 LEDs
 STM32F407
 Wooden Piece
 Veroboard
 Resistors
 Wires
 Soldering Iron
 A laptop with Installed Keil

3.2 Design the Template of Cube:

We used a piece of wood to build the cube frame. This was done by drilling machine. 16 holes were made
in the wooden piece so that 16 LEDs can be fitted in those holes and can be connected in same manner.
As shown in Figure. 1

FIGURE. 1 DESIGNING WOODEN TEMPLATE

3.3 Solder the circuit:

Using a soldering iron, LEDs were connected in a frame. 4 such frames were made to make a tower.

Each frame has 16 LEDs. Thee were two methods of making this frame, the first one was to connect the
LEDs own legs and the second was to connect two terminals of LEDs with separate conducting wires. We
felt ease at connecting a separate wire hence we took a conducting wire divide it into many small pieces
2
and started connecting it with our LEDs using soldering by firstly checking each led separately and then
place it in the wooden piece of wooden board. As shown in FigurE.2

FIGURE.2 SOLDERING LEDS

3.4 Install the Circuit:

Once the first frame wa completed, install the circuit board inside the frame and connect it to the LEDs.
By making it sure that all the LEDs are properly aligned with their corresponding holes in the frame. As

shown in Figure.

FIGURE.3 MAKING TOWER

3.5 Code for Cube:

After making cube we had to make an assembly code in keil that will use STM32F407 to connect our

Cube with the code. Following things were consider before writing code.
3
 We have to enable specific ports using GPIO MODE REGISTER, for that we checked the
datasheet and finalized the ports and pins that we were going to use.
 After this we enabled particular ports and their respective pins so that we can use them to do a
connection between hardware and software.
 Then we have to give instruction that what type of our output is whether it is push pull or is it
open drain using OUTPUT TYPE REGISTER. If our command is 0 that means we will select a
push pull output type but if we change it to bit 1 then our output type will be open drain.
 Then we will move to OSPEEDER register to set the speed of the LEDs.
 After this our focus will move towards PUPDR register and we will select our type i.e No Pull up
Pull Down.
 Finally we will give command to ODR as 1 incase we want to make LED on.
 Once simple code was completed we focused on the delay of the our project.
 Different sequences were made to give a nice effect to the cube.
 And finally after implementation and debugging of errors we were able to make a code that
matched our expectations.

Following are the pictures of our working cube

FIGURE 4 . LED CUBE

3.6 Test and Debug:

When finally the cube was made and tested there were a few mistakes in our code that we resolved and
got our final project in this look.

4. RESULT
Our result of assembly code is shown below

4.1 Code
;********************************************GROUP#1****************************************************
4
;*****************************************2020-EE-634(L)************************************************
;*****************************************2020-EE-611***************************************************
;*****************************************2020-EE-626***************************************************
;*****************************************2020-EE-639***************************************************
;*******************************************************************************************************
; Code for LED cube
;*******************************************************************************************************
INCLUDE core_cm4_constants.s ; Load Constant Definitions
INCLUDE stm32f401xc_constants.s

AREA findMax, CODE


EXPORT __main
ALIGN
ENTRY
__main PROC

; Enable Clock of GPIO Port E


LDR r7, =RCC_BASE
LDR r1, [r7, #RCC_AHB1ENR]
ORR r1, r1, #RCC_AHB1ENR_GPIOEEN
MOV r1, #0x00000016
MOV r2, #0x00000016
MOV r3, #0x00000016
STR r1, [r7, #RCC_AHB1ENR]
STR r2, [r8, #RCC_AHB1ENR]
STR r3, [r9, #RCC_AHB1ENR]

LDR r7, =GPIOE_BASE ; Load GPIO Port E base address


LDR r8, =GPIOC_BASE ; Load GPIO Port C base address
LDR r9, =GPIOB_BASE ; Load GPIO Port B base address

; Set Pin 9 I/O direction as Digital Output


LDR r1, [r7, #GPIO_MODER] ; r1 = GPIOE->MODER
BIC r1, r1, #0xFFFFFFFF ; Clear mode
ORR r1, r1, #0x55555555 ; Input(00, reset), Output(01), Alternate Func(10), Analog(11)
STR r1, [r7, #GPIO_MODER] ;

; Set Pin 9 the push-pull mode for the output type


LDR r1, [r7, #GPIO_OTYPER] ; OTYPER (32-bit)
BIC r1, r1, #0x00000000 ; Output Push-Pull(0, reset), Output Open-Drain(1)
STR r1, [r7, #GPIO_OTYPER]

; Set I/O output speed value as high speed


LDR r1, [r7, #GPIO_OSPEEDR]
ORR r1, r1, #0x55555555 ; Low speed (00), Medium speed (01), Fast speed(01), High speed (11)
STR r1, [r7, #GPIO_OSPEEDR]

; Set I/O as no pull-up pull-down


LDR r1, [r7, #GPIO_PUPDR] ; PUPDR (32-bit): configure I/O pull-up or pull-down
BIC r1, r1, #0xFFFFFFFF ; No PUPD(00, reset), Pull up(01), Pull down (10), Reserved (11)
STR r1, [r7, #GPIO_PUPDR]
;Enable port C
;Enable ports of C
LDR r2, [r8, #GPIO_MODER] ; r1 = GPIOE->MODER
5
BIC r2, r2, #0xFFFFFFFF ; Clear mode
ORR r2, r2, #0x55555555 ; Input(00, reset), Output(01), Alternate Func(10), Analog(11)
STR r2, [r8, #GPIO_MODER] ;

; Set Pin 9 the push-pull mode for the output type


LDR r2, [r8, #GPIO_OTYPER] ; OTYPER (32-bit)
BIC r2, r2, #0x00000000 ; Output Push-Pull(0, reset), Output Open-Drain(1)
STR r2, [r8, #GPIO_OTYPER]

; Set I/O output speed value as high speed


LDR r2, [r8, #GPIO_OSPEEDR]
ORR r2, r2, #0x55555555 ; Low speed (00), Medium speed (01), Fast speed(01), High speed (11)
STR r2, [r8, #GPIO_OSPEEDR]

; Set I/O as no pull-up pull-down


LDR r2, [r8, #GPIO_PUPDR] ; PUPDR (32-bit): configure I/O pull-up or pull-down
BIC r2, r2, #0xFFFFFFFF ; No PUPD(00, reset), Pull up(01), Pull down (10), Reserved (11)
STR r2, [r8, #GPIO_PUPDR]
;Enable port B

; Set Pin 9 I/O direction as Digital Output


LDR r3, [r9, #GPIO_MODER] ; r1 = GPIOE->MODER
BIC r3, r3, #0xFFFFFFFF ; Clear mode
ORR r3, r3, #0x55555555 ; Input(00, reset), Output(01), Alternate Func(10), Analog(11)
STR r3, [r9, #GPIO_MODER] ;

; Set Pin 9 the push-pull mode for the output type


LDR r3, [r9, #GPIO_OTYPER] ; OTYPER (32-bit)
BIC r3, r3, #0x00000000 ; Output Push-Pull(0, reset), Output Open-Drain(1)
STR r3, [r9, #GPIO_OTYPER]

; Set I/O output speed value as high speed


LDR r3, [r9, #GPIO_OSPEEDR]
ORR r3, r3, #0x55555555 ; Low speed (00), Medium speed (01), Fast speed(01), High speed (11)
STR r3, [r9, #GPIO_OSPEEDR]

; Set I/O as no pull-up pull-down


LDR r3, [r9, #GPIO_PUPDR] ; PUPDR (32-bit): configure I/O pull-up or pull-down
BIC r3, r3, #0xFFFFFFFF ; No PUPD(00, reset), Pull up(01), Pull down (10), Reserved (11)
STR r3, [r9, #GPIO_PUPDR]

MOV r4,#0x100
loop2
LDR r2, [r8, #GPIO_ODR] ;1
ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #15
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;2


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #13
STR r2, [r8, #GPIO_ODR]
BL delay
6
LDR r2, [r8, #GPIO_ODR] ;3
ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #11
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;4


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #9
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;5


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #14
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;6


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #6
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;7


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #4
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;8


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #2
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;9


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #8
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;10


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #10
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;11


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #12
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;12


7
ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #14
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;13


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #15
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;14


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #13
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;15


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #11
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;16


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #13
STR r1, [r7, #GPIO_ODR]
BL delay

looop3 LDR r2, [r8, #GPIO_ODR] ;C15


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #15
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E2


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #2
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E8


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #8
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E13


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #13
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;B11


ORR r3, r3, #GPIO_ODR_ODR_0
8
LSL r3, #11
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E10


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #10
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E4


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #4
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C13


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #13
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C11


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #11
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E6


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #6
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E12


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #12
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;B13


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #11
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;B16


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #16
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E14


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #14
9
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C14


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #14
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C9


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #9
STR r2, [r8, #GPIO_ODR]
BL delay

LOOP4 LDR r2, [r8, #GPIO_ODR] ;C9


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #9
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C11


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #11
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C13


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #13
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r2, [r8, #GPIO_ODR] ;C15


ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #15
STR r2, [r8, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E4


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #4
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E12


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #12
STR r1, [r7, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;B15


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #15
10

STR r3, [r9, #GPIO_ODR]


BL delay

LDR r3, [r9, #GPIO_ODR] ;B13


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #13
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r3, [r9, #GPIO_ODR] ;B11


ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #11
STR r3, [r9, #GPIO_ODR]
BL delay

LDR r1, [r7, #GPIO_ODR] ;E13


ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #13
STR r1, [r7, #GPIO_ODR]
BL delay

SUB r4,#1
CMP r4,#0
BGT loop2

B stop

delay MOV r5, #0x90000


loop SUB r5, #0x1
CMP r5, #0x0
BGT loop
;Clear all bits
LDR r1, [r7, #GPIO_ODR]
ORR r1, r1, #GPIO_ODR_ODR_0
LSL r1, #31
STR r1, [r7, #GPIO_ODR]
LDR r2, [r8, #GPIO_ODR]
ORR r2, r2, #GPIO_ODR_ODR_0
LSL r2, #31
STR r2, [r8, #GPIO_ODR]
LDR r3, [r9, #GPIO_ODR]
ORR r3, r3, #GPIO_ODR_ODR_0
LSL r3, #31
STR r3, [r9, #GPIO_ODR]
BX lr

stop B stop ;dead Loop


ENDP
END
11
4.2 Keil Simulations

FIGURE.5 KEIL SIMULATION OF OUR CODE

5. INNOVATIONS IN LED CUBE


This cube met our expectations but there is always room for improvement, we can do a lot of modifications
in it to make it more attractive, following are some of the techniques that can make our cube worth having.

5.1 New LED technologies:


LED technology is constantly evolving, and new types of LEDs with improved performance or novel
features could be used in LED cubes. For example, LED cubes might incorporate LEDs that can change
color, emit multiple wavelengths of light, or are more energy efficient.

5.2 Interactive controls:


LED cubes could be made more interactive by adding sensors or other input devices, such as touch screens
or voice recognition. This would allow users to control the LED cube in real-time or customize the lighting
patterns and effects.

5.3 Improved durability:


LED cubes are often used in public spaces or as decorative displays, and they may be subjected to rough
handling or extreme conditions. Developing new materials or construction techniques that make LED
cubes more durable could increase their lifespan and reduce maintenance requirements.

6. CONCLUSION
To conclude, making 4 by 4 cube was fun. There was a lot to learn, from soldering frames to making a
tower and from starting a code to finalizing it and giving it sequences. To create an LED cube, we gathered
the necessary materials and tools, including a microcontroller or development board, individual LED
12
modules, a prototyping board for soldering the LED modules, and wires for connecting everything
together. We also wanted to design and print a 3D enclosure for our LED cube to protect it and make it
more visually appealing. Once we had all materials, we solder the LED modules to the vero board, connect
everything to the microcontroller, and wrote and upload code to control the LED cube.

13

You might also like