自制最小系统驱动数码管
接线方法见强哥教程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++;
}
}
这个好,代码真整洁,支持一下 这个show()函数最好带个参数,方便一般调用。
页:
[1]