- byte smg[10][8] = { //设置每个数字所对应的开关数组
- { 1,0,0,0,0,1,0,0 }, // = 0
- { 1,0,0,1,1,1,1,1 }, // = 1
- { 1,1,0,0,1,0,0,0 }, // = 2
- { 1,0,0,0,1,0,1,0 }, // = 3
- { 1,0,0,1,0,0,1,1 }, // = 4
- { 1,0,1,0,0,0,1,0 }, // = 5
- { 1,0,1,0,0,0,0,0 }, // = 6
- { 1,0,0,0,1,1,1,1 }, // = 7
- { 1,0,0,0,0,0,0,0 }, // = 8
- { 1,0,0,0,0,0,1,0 } // = 9
- };
- void setup()
- {
- pinMode(2,INPUT);
- for(int x = 4; x <= 11;x ++)
- {
- pinMode(x,OUTPUT);
- }
- }
- void loop()
- {
-
- for(int j = 0;j <= 9;j ++)
- {
- int pin = 4;
- for(int i = 0;i <= 7;i ++)
- {
- digitalWrite(pin,smg[j][i]);
- pin ++;
- }
- delay(50);
- while(digitalRead(2))
- {
- delay(1000);
- }
- }
- }
复制代码 我也来写一段代码试试。 |