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 }