用51单片机控制74hc138,用74hc245来驱动数码管动态显示,为什么不加下面高亮部分的延时,数码管显示会变暗,不是有74hc245芯片的驱动吗?为什么还必须要有延时?
#include <reg52.h>
sbit yi=P2^0;
sbit er=P2^1;
sbit san=P2^2;
typedef unsigned char uchar;
typedef unsigned int uint;
#define shumaguan P0
uchar code shumaguanshuzi[ ]={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void dongtaisaomiao( );
void delay_ms(uin);
uchar i;
void main ( ){
while ( 1 )
dongtaisaomiao( );
}
void dongtaisaomiao( ){
for(i=0;i<8;i++){
switch (i){
case 0:yi=0;er=0;san=0;break;
case 1:yi=1;er=0;san=0;break;
case 2:yi=0;er=1;san=0;break;
case 3:yi=1;er=1;san=0;break;
case 4:yi=0;er=0;san=1;break;
case 5:yi=1;er=0;san=1;break;
case 6:yi=0;er=1;san=1;break;
case 7:yi=1;er=1;san=1;break;
}
shumaguan=shumaguanshuzi
;
//delay_ms(1);
shumaguan=0x00;
}
}
void delay_ms(uint time ){
uint i,k;
for(i=0;i<time;i++)
for(k=0;k<124;k++);
}
此帖出自小平头技术问答
恩恩,有种流水灯的效果;问题是为什么会变暗好多呢
一周热门 更多>