1. A 4x4 matrix composed of three-color LED lights, distributed on the 6 faces of the cube.
2. LED lights are connected in series.
3. The lights on each side are connected in series through connectors.
4. Serial communication through Renesas MCU SPI pin.
5. The color of the lamp can change gradually.
LED matrix serial connection
Inter-board interconnect connector
Renesas MCU
Code block:
#define FACE_NUM 6 //共6个面
#define PIXEL_NUM_OF_FACE 16 //一个面16个灯
#define BIT_OF_PIXEL 24 //一个灯有24bit数据
#define PIXEL_NUM 96 //共96个灯
#define LED_BIT (PIXEL_NUM * BIT_OF_PIXEL) //LED灯共这些bit数据
uint8_t Pixel_Buffer[FACE_NUM][PIXEL_NUM_OF_FACE][BIT_OF_PIXEL];
uint8_t color_face_1[6][3] = {{128 , 0 , 0},{64 , 64 , 0},{ 0 , 128 , 0},{ 0 , 64 , 64},{ 0 , 0 , 128},{ 64 ,0 , 64}};
uint8_t Color_Buffer_of_Face[PIXEL_NUM_OF_FACE][3] = {
{128 , 0 , 0},{104 , 24 , 0},{ 80 , 48 , 0},{ 56 , 72 , 0},
{ 32 , 96 , 0},{ 8 ,120 , 0},{ 0 ,112 , 16},{ 0 , 88 , 40},
{ 0 , 64 , 64},{ 0 , 40 , 88},{ 0 , 16 ,112},{ 8 , 0 ,120},
{ 32 , 0 , 96},{ 56 , 0 , 72},{ 80 , 0 , 48},{104 , 0 , 24},
};
void LED_Set_Color(uint8_t color,uint8_t *position)
{
uint8_t zero = 0x30; //00110000
uint8_t one = 0xF8; //11111000
uint8_t k = 0;
uint8_t mask = 0x80;
for(k=0;k<8;k++)
{
position[k] = ((color & mask) ? one : zero);
mask >>= 1;
}
}
for(cnt_f=0;cnt_f<FACE_NUM;cnt_f++) //6个面
{
for(cnt_p=0;cnt_p<PIXEL_NUM_OF_FACE;cnt_p++) //16个像素
{
for(cnt_b=0;cnt_b<3;cnt_b++) //每个像素3种颜色
{
LED_Set_Color(color_face_1[cnt_f][cnt_b],&Pixel_Buffer[cnt_f][cnt_p][cnt_b*8]);
}
}
}
for(cnt_p=0;cnt_p<FACE_NUM;cnt_p++) //16个像素颜色变换
{
if((color_face_1[cnt_p][0] != 0) && (color_face_1[cnt_p][2] == 0))
{
color_face_1[cnt_p][0]--;
color_face_1[cnt_p][1]++;
}
else if((color_face_1[cnt_p][0] == 0) && (color_face_1[cnt_p][1] != 0))
{
color_face_1[cnt_p][1]--;
color_face_1[cnt_p][2]++;
}
else if((color_face_1[cnt_p][1] == 0) && (color_face_1[cnt_p][2] != 0))
{
color_face_1[cnt_p][2]--;
color_face_1[cnt_p][0]++;
}
}
err = R_SPI_Write(&g_spi0_ctrl, Pixel_Buffer, LED_BIT, SPI_BIT_WIDTH_8_BITS);
assert(FSP_SUCCESS == err);
R_BSP_SoftwareDelay(5, BSP_DELAY_UNITS_MILLISECONDS); // NOLINT100->160
The hardware design of this project is a replica of the "KeG Stack" work. The main design has basically remained unchanged. The main control MCU has been replaced with R7FA2L1AB2DFL#AA0.
The link is as follows:
https://www.bilibili.com/video/BV1ev411k7mh?spm_id_from=333.999.0.0
Code design reference:
https://blog.csdn.net/geek_liyang/article/details/89208507?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0-89208507-blog-84638967 .pc_relevant_paycolumn_v3&spm=1001.2101.3001.4242.1&utm_relevant_index=3
1. In order to connect the 6-sided lights in series in the design, PCBs with two wiring directions need to be spliced. I think the connector connection method can be optimized here, and a PCB board can be used to realize the series connection of 6 surface lights.
see attached
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet