如题。连线:
程序:
- int patternCount=18;
- int ledCount=6;
-
- int ledOut[] = {11,10,9,6,5,3};
-
- int brightness[6]={0,3,7,15,63,255};
- int pattern[18][6]={
- 0, 0, 0, 0, 0, 5,
- 0, 0, 0, 0, 5, 4,
- 0, 0, 0, 5, 4, 3,
- 0, 0, 5, 4, 3, 2,
- 0, 5, 4, 3, 2, 1,
- 5, 4, 3, 2, 1, 0,
- 5, 3, 2, 1, 0, 0,
- 5, 2, 1, 0, 0, 0,
- 5, 1, 0, 0, 0, 0,
- 5, 0, 0, 0, 0, 0,
- 4, 5, 0, 0, 0, 0,
- 3, 4, 5, 0, 0, 0,
- 2, 3, 4, 5, 0, 0,
- 1, 2, 3, 4, 5, 0,
- 0, 1, 2, 3, 4, 5,
- 0, 0, 1, 2, 3, 5,
- 0, 0, 0, 1, 2, 5,
- 0, 0, 0, 0, 1, 5}
- ;
- int patternSeq=-1;
-
- void setup() {
- }
-
- void loop() {
- int i;
- patternSeq++;
- if(patternSeq>=patternCount)
- {
- patternSeq=0;
- }
- for(i=0;i<ledCount;i++)
- {
- analogWrite(ledOut[i], brightness[pattern[patternSeq][i]]);
- }
- if(patternSeq==0 || patternSeq==9)
- {
- delay(500);
- }
- else
- {
- delay(100);
- }
- }
复制代码
效果:
|