從黑體的地方開(kāi)始,我想通過(guò)矩陣鍵盤控制數(shù)碼管顯示0-15,但是不知道怎么搞兩位數(shù)的顯示,是不是延時(shí)什么的有問(wèn)題
#include
sfr P4 = 0xC0;
unsigned char code duanma[18]={
? 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x80,0xc0,0x86,0x8e,0xbf,0x7f};
sbit R1 = P3^0;
sbit R2 = P3^1;
sbit R3 = P3^2;
sbit R4 = P3^3;
sbit C1 = P3^4;
sbit C2 = P3^5;
sbit C3 = P4^2;
sbit C4 = P4^4;
void HC573(unsigned char one)
{
? switch(one)
? {
? case 4:
? P2 = (P2 & 0x1f) | 0X80;
? break;
? case 5:
? P2 = (P2 & 0x1f) | 0xa0;
? break;
? case 6:
? P2 = (P2 & 0X1f) | 0Xc0;
? break;
? case 7:
? P2 = (P2 & 0X1f) | 0Xe0;
? break;
? }
???}
void Delay(unsigned char t)
{
? while(t--);
}
void SHUMA(unsigned char two, unsigned char thr )
{
? HC573(6);
? P0 = 0x01<< thr;
? HC573(7);
? P0 = two;
}
unsigned char num = 0, yum = 0;
void Juzhen()
{
? C1 = 0; C2 = C3 = C4 = 1;
? R1 = R2 = R3 = R4 = 1;
? if(R1 == 0)
? {
? while(R1 == 0);
? num =0??;
? SHUMA(duanma[num],1);
? }
? else if(R2 == 0)
? {
? while(R2 == 0);
? num = 1 ;
? SHUMA(duanma[num],1);
? }
? else if(R3 == 0)
? {
? while(R3 == 0);
? num =??2;
? SHUMA(duanma[num],1);
? }
? else if(R4 == 0)
? {
? while(R4 == 0);
? num =??3;
? SHUMA(duanma[num],1);
? }
? C2 = 0; C1 = C3 = C4 = 1;
? R1 = R2 = R3 = R4 = 1;
? if(R1 == 0)
? {
? while(R1 == 0);
? num =??4;
? SHUMA(duanma[num],1);
? }
? else if(R2 == 0)
? {
? while(R2 == 0);
? num =??5;
? SHUMA(duanma[num],1);
? }
? else if(R3 == 0)
? {
? while(R3 == 0);
? num =??6;
? SHUMA(duanma[num],1);
? }
? else if(R4 == 0)
? {
? while(R4 == 0);
? num =??7;
? SHUMA(duanma[num],1);
? }
? C3 = 0; C2 = C1 = C4 = 1;
? R1 = R2 = R3 = R4 = 1;
? if(R1 == 0)
? {
? while(R1 == 0);
? num =??8;
? SHUMA(duanma[num],1);
? }
? else if(R2 == 0)
? {
? while(R2 == 0);
? num =??9;
? SHUMA(duanma[num],1);
? }
??else if(R3 == 0)
? {
? while(R3 == 0);
? num = 0 , yum = 1;
? SHUMA(duanma[num],1);
? Delay(100);
? SHUMA(duanma[yum],0);
? Delay(100);
? }
? else if(R4 == 0)
? {
? while(R4 == 0);
? num = 1,yum = 1 ;
? SHUMA(duanma[num],1);
? Delay(100);
? SHUMA(duanma[yum],0);
? while(R4 == 0);
? }
? C4 = 0; C2 = C3 = C1 = 1;
? R1 = R2 = R3 = R4 = 1;
? if(R1 == 0)
? {
? while(R1 == 0);
? num = 2,yum = 1 ;
? SHUMA(duanma[num],1);
? Delay(500);
? SHUMA(duanma[yum],0);
? }
? else if(R2 == 0)
? {
? while(R2 == 0);
? num = 3,yum = 1 ;
? SHUMA(duanma[num],1);
? Delay(500);
? SHUMA(duanma[yum],0);
? }
? else if(R3 == 0)
? {
? while(R3 == 0);
? num = 4,yum = 1 ;
? SHUMA(duanma[num],1);
? Delay(500);
? SHUMA(duanma[yum],0);
? }
? else if(R4 == 0)
? {
? while(R4 == 0);
? num = 5 ,yum = 1;
? SHUMA(duanma[num],1);
? Delay(500);
? SHUMA(duanma[yum],0);
? }
}
void main()
{
? while(1)
? {
? Juzhen();
? }
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧