flashria 发表于 2012-11-23 23:23:35

自制最小系统驱动数码管

接线方法见强哥教程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 = {
{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);      
    x++;
}
}

shenhaiyu 发表于 2012-11-24 16:38:44

这个好,代码真整洁,支持一下

zcbzjx 发表于 2012-12-23 14:03:37

这个show()函数最好带个参数,方便一般调用。
页: [1]
查看完整版本: 自制最小系统驱动数码管