6318| 2
|
[求助] 入门萌新救助一段代码解释 |
数码管实验学习,以下这段代码是教程中的,求助一些问题,底子比较薄若,希望有前辈指点迷津。:'(:'( byte seven_seg_digits[10][8] = { (这一段是什么意思呢?看不懂结构,能帮忙明细一下吗?):dizzy: { 1,0,0,0,0,1,0,0 }, { 1,0,0,1,1,1,1,1 }, { 1,1,0,0,1,0,0,0 }, { 1,0,0,0,1,0,1,0 }, { 1,0,0,1,0,0,1,1 }, { 1,0,1,0,0,0,1,0 }, { 1,0,1,0,0,0,0,0 }, { 1,0,0,0,1,1,1,1 }, { 1,0,0,0,0,0,0,0 }, { 1,0,0,0,0,0,1,0 } }; void setup() { pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); } void sevenSegWrite(byte digit) { (这一段是彻底看不懂了,教程解释的太笼统了,无法消化,求高人明细):dizzy: byte pin = 4; for (byte segCount = 0; segCount < 8; ++segCount) { digitalWrite(pin, seven_seg_digits[digit][segCount]); ++pin; } } void loop() { for (byte count = 10; count > 0; --count) { delay(1000); sevenSegWrite(count - 1); (这到底是什么意思呢?):'( } delay(2000); } 求好心高人指点一下,晚辈拜谢了。。。 |
byte seven_seg_digits[10][8] = { (这一段是定义了一段显示数字时候用到的数据,每一个大括号里面的一串表示一个数字 { 1,0,0,0,0,1,0,0 }, { 1,0,0,1,1,1,1,1 }, { 1,1,0,0,1,0,0,0 }, { 1,0,0,0,1,0,1,0 }, { 1,0,0,1,0,0,1,1 }, { 1,0,1,0,0,0,1,0 }, { 1,0,1,0,0,0,0,0 }, { 1,0,0,0,1,1,1,1 }, { 1,0,0,0,0,0,0,0 }, { 1,0,0,0,0,0,1,0 } }; void setup() { pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); } void sevenSegWrite(byte digit) { (这一段就是把上面那个定义的数据里面的一个大括号的数据 显示出来 byte pin = 4; for (byte segCount = 0; segCount < 8; ++segCount) { digitalWrite(pin, seven_seg_digits[digit][segCount]); ++pin; } } void loop() { for (byte count = 10; count > 0; --count) { delay(1000); sevenSegWrite(count - 1); (一个循环,把上面的数据一个大括号一个大括号的分开来显示) } delay(2000); } |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed