2020-11-26
程序员文章站
2022-03-06 08:14:56
#define D_a 2 //数码管a 接引脚 2#define D_b 3#define D_c 4#define D_d 5#define D_e 6#define D_f 7#define D_g 8#define D_h 9 //数码管0-F数字码值unsigned char num[20][8] ={ //1为点亮,0为关闭,a表示数码管a的led灯,其他类似 //a b c d e f g h {1, 1, 1, 1, 1, 1, 0, 0},...
#define D_a 2 //数码管a 接引脚 2
#define D_b 3
#define D_c 4
#define D_d 5
#define D_e 6
#define D_f 7
#define D_g 8
#define D_h 9
//数码管0-F数字码值
unsigned char num[20][8] =
{
//1为点亮,0为关闭,a表示数码管a的led灯,其他类似
//a b c d e f g h
{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
{1, 1, 1, 1, 0, 0, 1, 0}, //3
{0, 1, 1, 0, 0, 1, 1, 0}, //4
{1, 0, 1, 1, 0, 1, 1, 0}, //5
{1, 0, 1, 1, 1, 1, 1, 0}, //6
{1, 1, 1, 0, 0, 0, 0, 0}, //7
{1, 1, 1, 1, 1, 1, 1, 0}, //8
{1, 1, 1, 1, 0, 1, 1, 0}, //9
{1, 1, 1, 1, 0, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{1, 0, 1, 1, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{1, 1, 1, 1, 0, 0, 1, 0},
{1, 1, 0, 1, 1, 0, 1, 0},
{0, 1, 1, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 0, 0},
};
void setup()
{
pinMode(D_a,OUTPUT); //设置引脚为输出
pinMode(D_b,OUTPUT); //设置引脚为输出
pinMode(D_c,OUTPUT); //设置引脚为输出
pinMode(D_d,OUTPUT); //设置引脚为输出
pinMode(D_e,OUTPUT); //设置引脚为输出
pinMode(D_f,OUTPUT); //设置引脚为输出
pinMode(D_g,OUTPUT); //设置引脚为输出
pinMode(D_h,OUTPUT); //设置引脚为输出
}
void loop()
{
//按顺序显示0123456789ABCDEF.
for( int i = 0 ; i < 20 ; i++) //循环显示0-9,9-0
{
digitalWrite(D_a,num[i][0]); //设置a 引脚的电平
digitalWrite(D_b,num[i][1]); //设置b 引脚的电平
digitalWrite(D_c,num[i][2]); //设置c 引脚的电平
digitalWrite(D_d,num[i][3]); //设置d 引脚的电平
digitalWrite(D_e,num[i][4]); //设置e 引脚的电平
digitalWrite(D_f,num[i][5]); //设置f 引脚的电平
digitalWrite(D_g,num[i][6]); //设置g 引脚的电平
digitalWrite(D_h,num[i][7]); //设置h 引脚的电平
delay(1000); //延迟1秒}}
本文地址:https://blog.csdn.net/m0_46234896/article/details/110204434