熱門: 51單片機(jī) | 24小時(shí)必答區(qū) | 單片機(jī)教程 | 單片機(jī)DIY制作 | STM32 | Cortex M3 | 模數(shù)電子 | 電子DIY制作 | 音響/功放 | 拆機(jī)樂園 | Arduino | 嵌入式OS | 程序設(shè)計(jì)
![]() |
發(fā)布時(shí)間: 2022-11-28 21:55
正文摘要:單片機(jī)獨(dú)立按鍵控制LED數(shù)碼管顯示數(shù)字及左移 仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載) |
U2是什么元件 |
終于找到關(guān)于多個(gè)數(shù)碼管動(dòng)態(tài)顯示的帖子了 |
請(qǐng)問使用矩陣鍵盤的話應(yīng)該怎么改 // 矩陣鍵盤讀取按鍵鍵碼 unsigned char MatrixKey() { unsigned char KeyNumber = 0; P1 = 0xFF; P1_3 = 0; if (P1_7 == 0) {Delay_ms(20); while (P1_7 == 0); Delay_ms(20); KeyNumber = 16;} if (P1_6 == 0) {Delay_ms(20); while (P1_6 == 0); Delay_ms(20); KeyNumber = 15;} if (P1_5 == 0) {Delay_ms(20); while (P1_5 == 0); Delay_ms(20); KeyNumber = 14;} if (P1_4 == 0) {Delay_ms(20); while (P1_4 == 0); Delay_ms(20); KeyNumber = 13;} P1 = 0xFF; P1_2 = 0; if (P1_7 == 0) {Delay_ms(20); while (P1_7 == 0); Delay_ms(20); KeyNumber = 12;} if (P1_6 == 0) {Delay_ms(20); while (P1_6 == 0); Delay_ms(20); KeyNumber = 11;} if (P1_5 == 0) {Delay_ms(20); while (P1_5 == 0); Delay_ms(20); KeyNumber = 10;} if (P1_4 == 0) {Delay_ms(20); while (P1_4 == 0); Delay_ms(20); KeyNumber = 9;} P1 = 0xFF; P1_1 = 0; if (P1_7 == 0) {Delay_ms(20); while (P1_7 == 0); Delay_ms(20); KeyNumber = 8;} if (P1_6 == 0) {Delay_ms(20); while (P1_6 == 0); Delay_ms(20); KeyNumber = 7;} if (P1_5 == 0) {Delay_ms(20); while (P1_5 == 0); Delay_ms(20); KeyNumber = 6;} if (P1_4 == 0) {Delay_ms(20); while (P1_4 == 0); Delay_ms(20); KeyNumber = 5;} P1 = 0xFF; P1_0 = 0; if (P1_7 == 0) {Delay_ms(20); while (P1_7 == 0); Delay_ms(20); KeyNumber = 4;} if (P1_6 == 0) {Delay_ms(20); while (P1_6 == 0); Delay_ms(20); KeyNumber = 3;} if (P1_5 == 0) {Delay_ms(20); while (P1_5 == 0); Delay_ms(20); KeyNumber = 2;} if (P1_4 == 0) {Delay_ms(20); while (P1_4 == 0); Delay_ms(20); KeyNumber = 1;} return KeyNumber; } |
Powered by 單片機(jī)教程網(wǎng)