7.led 灯珠矩阵

一、功能以及原理

原理:led 灯珠矩阵可以根据用户的需求,让一定行数与列数的 led 灯点亮为特定颜色

二、引脚介绍以及对应开发板可用引脚

led 灯珠矩阵:

GND: 接地,连接 Arduino 板的 GND

DOUT: 接收输出信号,连接 Arduino 板的数字引脚(0~13),暂不连接

DIN:输入信号,根据输出信号变成特定颜色,连接 Arduino 板的数字引脚(0~13)

VSS:电源供电,连接 Arduino 板的 5V

三、代码控制

  • 初始化 led 矩阵,亮度调为 180
  • 前六列与前六行的 led 灯珠变为红色,1 秒后变为绿灯,循环进行
  • 电路连接图可参照相关案例演示

3.1 文本代码

#include "FastLED.h"


#define NUM_ROWS 8
#define NUM_COLS 8

CRGB leds[NUM_ROWS * NUM_COLS];


void setup() {
  FastLED.addLeds<NEOPIXEL, 3>(leds, NUM_ROWS * NUM_COLS);
  FastLED.setBrightness(180);

}

void loop() {
    for (byte row = 0; row < 6; row++) {
      for (byte col = 0; col < 6; col++) {
        leds[row * NUM_COLS + col] = CHSV(0, 100, 100);
      }
    }
    FastLED.show();
    delay(1 * 1000);
    for (byte row = 0; row < 6; row++) {
      for (byte col = 0; col < 6; col++) {
        leds[row * NUM_COLS + col] = CHSV(156, 100, 100);
      }
    }
    FastLED.show();
    delay(1 * 1000);

}

3.2 图形化代码

可在“显示器”中的“LED 灯珠矩阵”,找到对应的图形化代码块。

四、相关案例演示

1、电路连接图

2、程序运行图

五、相关课程链接

  1. https://www.funcode.cc/course-learn/detail?courseId=65&from=courseList
  2. https://www.funcode.cc/course-learn/detail?courseId=62&from=courseList
  3. 【Arduino 精选项目——绚烂的 LED 灯矩阵】 https://www.bilibili.com/video/BV1h32hYfEEc/?share_source=copy_web&vd_source=7eafc622b20fbde30ea1853f07bc5a80

results matching ""

    No results matching ""