|
發(fā)布時間: 2022-11-28 21:55
正文摘要:單片機(jī)獨(dú)立按鍵控制LED數(shù)碼管顯示數(shù)字及左移 仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載) |
| U2是什么元件 |
| 終于找到關(guān)于多個數(shù)碼管動態(tài)顯示的帖子了 |
|
請問使用矩陣鍵盤的話應(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)