LED 5mm CN: 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: {{#seo:|title=ArduWiki: Arduino LED Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Evaluation, LED, Arduino Projects, Capstone Projects, Arduino Example Code|description=Introduces how to control LEDs with Arduino (basic information, circuit, example code). Can be used in Information Science and Maker classes.}} center|class=coders100 Apply a constant voltage to emit light. The longer leg is the posi...)
 
잔글편집 요약 없음
 
(같은 사용자의 중간 판 하나는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{#seo:|title=ArduWiki: Arduino LED Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Evaluation, LED, Arduino Projects, Capstone Projects, Arduino Example Code|description=Introduces how to control LEDs with Arduino (basic information, circuit, example code). Can be used in Information Science and Maker classes.}}
{{#seo:|title=Arduino维基:Arduino LED指南|title_mode=append|keywords=Arduino, 信息科学, 创客学习, 性能评估, LED, Arduino项目, 毕业设计项目, Arduino示例代码|description=介绍如何使用Arduino控制LED(基本信息、电路、示例代码)。可用于信息科学和创客课程。}}
[[File:5mmled대표이미지.jpg|center|class=coders100]]
[[File:5mmled대표이미지.jpg|center|class=coders100]]
Apply a constant voltage to emit light.


The longer leg is the positive (+) terminal and the shorter one is the negative (-) terminal, so caution is needed when connecting.
通过输入恒定电压来发光。


Be careful not to supply a voltage higher than the maximum voltage of the product.
长脚为正极(+),短脚为负极(-),连接时需注意。


== '''Specifications''' ==
注意不要提供超过产品最大电压的电压。
These are the specifications of the LED discussed in the text. Specifications may vary slightly depending on the manufacturer and model.
 
 
== '''规格''' ==
这里介绍的LED规格,具体规格可能因制造商和型号而有所不同。
{| class="wikitable"
{| class="wikitable"
| colspan="1" rowspan="1" |Color
| colspan="1" rowspan="1" |Color
39번째 줄: 41번째 줄:
|}
|}


== '''Required Hardware''' ==
 
== '''所需硬件''' ==


* LED
* LED
* Arduino board
* Arduino board
* Jumper cables


* Jumper cables


== '''Connection''' ==
== '''连接''' ==
Connect the longer leg through a resistor to a digital pin, and the shorter leg to the Arduino's GND.
将长脚通过电阻器连接到数字引脚,将短脚连接到Arduino的GND。


You can connect the long legs together to operate from a single digital pin as shown below, or set different digital pins for each LED if you want them to operate separately.
如下例所示,可以将长脚连接在一起从一个数字引脚控制,或者为每个LED设置单独的数字引脚以实现独立控制。
{| class="wikitable"
{| class="wikitable"
| colspan="1" rowspan="1" |Component
| colspan="1" rowspan="1" |Component
70번째 줄: 72번째 줄:
[[File:Led 회로.png|center|class=coders70]]
[[File:Led 회로.png|center|class=coders70]]


== '''Example Code''' ==
== '''示例代码''' ==
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#define led 7 // Use pin 7
#define led 7 // Use pin 7
88번째 줄: 90번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== Execution Result ===
=== '''执行结果''' ===
[[File:Led 시연.jpg|center|class=coders100]]
[[File:Led 시연.jpg|center|class=coders100]]

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);
}

执行结果