int setPins[] = {7,6,4,2,1,9,10,5};
byte digits[3][8]={{1,1,1,1,1,1,0,0},//数字0
{0,1,1,0,0,0,0,0},//数字1
{1,1,0,1,1,0,1,0} //数字2
};
void setup() {
// put your setup code here, to run once:
for(int i=0;i<8;i++)
{
pinMode(setPins[i],OUTPUT); //端口初始化为输出
}
pinMode(3,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(3,LOW);
for(int n=0;n<=2;n++)
{
for(int j=0;j<8;j++)
{
digitalWrite(setPins[j],digits[n][j]);//按下按键开关1数码管显示1
}
delay(1000);
}
}