接线方法见强哥教程http://www.geek-workshop.com/thread-2038-1-1.html
强哥写的代码不敢恭维,哈哈哈,我自己又整理了份 重新传下吧。 - void setup() {
- pinMode(13,OUTPUT);
- for(int n=2;n<=9;n++) {
- pinMode(n,OUTPUT);
- }
- }
- byte numbers[10][8] = {
- {0,0,0,0,0,0,1,1}, // = 0
- {1,0,0,1,1,1,1,1}, // = 1
- {0,0,1,0,0,1,0,1}, // = 2
- {0,0,0,0,1,1,0,1}, // = 3
- {1,0,0,1,1,0,0,1}, // = 4
- {0,1,0,0,1,0,0,1}, // = 5
- {0,1,0,0,0,0,0,1}, // = 6
- {0,0,0,1,1,1,1,1}, // = 7
- {0,0,0,0,0,0,0,1}, // = 8
- {0,0,0,0,1,0,0,1} // = 9
- };
- int index=0;
- void loop()
- {
- digitalWrite(13,1);
- show();
- index++;
- if(index>9)index=0;
- delay(1000);
- }
- void show(){
- int x=2;
- for(int z=0;z<8;z++)
- {
- digitalWrite(x,numbers[index][z]);
- x++;
- }
- }
复制代码
|