Skip to content

zebra314/led_cube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LED Cube

About

This is the final project for Microprocessor_2023, my partner @chrispies181 and I build a 5x5x5 LED cube. LED_cube Animation

Material List

  • STM32L476RG x 1 stm32l476rg
  • yellow LEDs x 125
  • 2n2222a transistor x 25
  • MAX7221 Led display drivers x 1 max7219

Steps

  1. Welding the led matrix:

    • To bend the pins of LEDs and arrange them from a row to a layer, and then assemble them into an LED cube.
    • In each layer, the positive pins connect with each other, the negative pins connect vertically with the LEDs of the top and bottom side from the other layers.
    • Make sure to the LEDs in the same layer are working properly before welding the next layer. single LED single layer LED cube
  2. Welding the transistor:

    • Using collector and base pins of the transistor to build a layer, take collector as the positive led pin and base as the negative led pin.
    • Connect emitter pins to the bottom layer of the LED cube vertically. transistor layer

Schematic

The most common way to control the LED cube is to use one MAX7219 for each layer (five max7219 for five layers), however we found that if we control the current flow by adding the transistor to the pins of max7219, we can use only one max7219 to control all the layers.

  • Single LED layer
    single led layer
  • Max7219 layer
    max7219 layer
  • Circuit diagram
    circuit diagram

Firmware

  • In component.h we define the pins of the LED cube, including the LED cube itself, the MAX7219, and the STM32L476RG. If change the pins of the LED cube, you need to change the pins in this file.

  • The struct LED_Matrix in component.h is used to store the status of the LED cube at instant, including:

    • the pins
    • update_rate
    • brightness
    • the lighten corrdinate
      • key: the x, y, z coordinate of the LED
      • value: 0 - off, 1 - on
    • the lighten layer
      • key: the layer of the LED cube
      • value: 0 - off, 1 - on
  • If you want to change the pattern of the LED cube, you need to change the struct LED_Matrix which will be used in the main.c.

  • In animation.h, we define how the LED cube works, it is not necessary to understand the code in this file, but you still can control the LED cube by change the struct LED_Matrix and import it into the display function.

Display control

void display(MAX7219* max7219_interface, LED_Matrix* led_matrix);

Example

  • In this example, we simulate a ball collision in the LED cube. The lighten LED represent the position the ball in the LED cube.
  • We use the struct Point in animation.h to store the position and vector of the ball, and using the colliding() to update the ball status. When the ball hitthe wall, it will bounce back base on it vector.
Point new_point = colliding(point);
test_matrix.lighten_coordinate[(int)(point.x_pos)][(int)(point.y_pos)][(int)(point.z_pos)] = 1;
display(&max7219_interface, &test_matrix);
point = new_point;

About

The final project of Microprocessor_2023

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published