【笔记】Arduino控制双色LED灯模块

前言

Arduino UNO R4控制双色LED灯模块

接线图

flowchart LR
  subgraph UNO ["Arduino UNO R4"]
    Pin_11(("~11"))
    Pin_10(("~10"))
    Pin_GND(("GND"))
  end

  subgraph Module ["双色LED灯模块"]
    A(("G(S)"))
    B(("R"))
    C(("GND(-)"))
  end

  Pin_11 --- B
  Pin_10 --- A
  Pin_GND --- C

源代码

analogWrite:输出值为0~255

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const int R_PIN = 11;
const int G_PIN = 10;

void setup()
{
pinMode(R_PIN, OUTPUT);
pinMode(G_PIN, OUTPUT);
}

void loop()
{
analogWrite(R_PIN, 255);
analogWrite(G_PIN, 0);
}

完成

参考文献

哔哩哔哩——创乐博智能科技