LED 5mm CN

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 2025년 3월 20일 (목) 20:29 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

通过输入恒定电压来发光。

长脚为正极(+),短脚为负极(-),连接时需注意。

注意不要提供超过产品最大电压的电压。


规格

这里介绍的LED规格,具体规格可能因制造商和型号而有所不同。

Color Minimum Voltage[V] Maximum Voltage[V] Standard Current[mA] Maximum Current[mA]
Red 1.8 2.3 20 50
Yellow 2 2.8
Green 3 3.6
Blue 3.4 3.8
White 3.4 4


所需硬件

  • LED
  • Arduino board
  • Jumper cables


连接

将长脚通过电阻器连接到数字引脚,将短脚连接到Arduino的GND。

如下例所示,可以将长脚连接在一起从一个数字引脚控制,或者为每个LED设置单独的数字引脚以实现独立控制。

Component Connection to Arduino Notes
LED(+) Connected to Resistor Resistor limits current to Protect LED
Resistor Connected to D7 Pin Recommended to use a resistor between 220Ω and 330Ω
LED(-) Connected to GND

示例代码

#define led 7 // Use pin 7
#define dly 1000

void setup() {
  pinMode(led, OUTPUT);
}

void loop() { // Code for turning on the LED for 1 second intervals
  digitalWrite(led, HIGH);
  delay(dly);
  digitalWrite(led, LOW);
  delay(dly);
}

执行结果