风轻云淡愿君赏,消尽烦忧心亮敞。夏去秋来添衣裳,一声问候祝安康!

Wemos D1 RGB 全彩灯

 

 RGB小灯依次点亮0-255级

 1 void setup(){
 2   pinMode(D13, OUTPUT);
 3   pinMode(D12, OUTPUT);
 4   pinMode(D11, OUTPUT);
 5   Serial.begin(115200);
 6 }
 7  int iex =0;
 8 int level = 0;
 9 int ports[3] = {D11,D12,D13};
10 
11 void loop(){
12   
13  for(;level<=255;level+=5)
14   {
15       Serial.print(iex);
16       Serial.print(" level:");
17       Serial.print(level);
18       Serial.println(" ok..");
19       analogWrite(ports[iex], level);
20       delay(50);
21       if(level>=255)
22       {level=0;
23         break;}
24     }
25   delay(100);
26   ++iex %= 3;
27 }

 

posted on 2021-08-13 20:53  荣林  阅读(121)  评论(0编辑  收藏  举报

导航