码迷,mamicode.com
首页 > 其他好文 > 详细

arduino#呼吸灯

时间:2020-01-08 14:29:20      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:arduino   oop   rem   class   nts   span   void   max   dpi   

int ledPin = 3;    // 使用引脚号

void setup() {
  // nothing happens in setup
}

void loop() {
  // fade in from min to max in increments of 5 points:
  for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 2) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }

  // fade out from max to min in increments of 5 points:
  for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 4) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }
}

arduino#呼吸灯

标签:arduino   oop   rem   class   nts   span   void   max   dpi   

原文地址:https://www.cnblogs.com/luohaonan/p/12166008.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!