案例来源:《Arduino程序设计基础》第二版

可通过Arduino中文社区获得该文内容:https://www.arduino.cn/thread-74477-1-1.html

img

void setup() {
  // put your setup code here, to run once:
  for(int i=2;i<8;i++)
  pinMode(i,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  for(int i=2;i<7;i++)
  {
    digitalWrite(i,HIGH);
    delay(1000);
    digitalWrite(i,LOW);
   }
   for(int i=7;i>2;i--)
   {
    digitalWrite(i,HIGH);
    delay(1000);
    digitalWrite(i,LOW);
    }
}

实现效果:

相关记录:

1.发光二极管的正负极

img

仔细观察发光二极管结构可以发现,一般长腿为阳极,短腿为阴极,也可根据内部结构来判断阴阳极,反光碗所在的一侧为阴极。

2.电阻阻值计算

img

根据上图可以轻松判断出电阻数值。

Last modified: 2021年2月27日

Comments

Write a Reply or Comment

Your email address will not be published.