消影笑过了,但是不知道为什么后面几个数码管还是有暗影,求大神解救!:handshake #include <iom16v.h> #include <macros.h> #define uchar unsigned char #define uint unsigned int #pragma data:code const SMG[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; void delay(uint ms) { uint i,j; for(i=0;i<ms;i++) for(j=0;j<1000;j++); } void show(uchar i,uchar j) { PORTB=0XFF; PORTA|=BIT(0); PORTB=SMG[i+1]; PORTA&=~BIT(0); PORTB=0XFF; PORTA|=BIT(1); PORTB&=~BIT(j); PORTA&=~BIT(1); delay(1); } void main() { uint k; uchar j; DDRA|=0X03; DDRB=0XFF; PORTB=0XFF; while(1) { /* for(k=0;k<800;k++) { for(j=0;j<8;j++) { show((j+k/100)%8,j); } }*/ show(2,1); } }
|