循环显示数码管数字依次增加,像外面的电子屏样的。用的是STCC52的开发板
- #include<reg52.h>
- #define uchar unsigned char
- sbit s1=P2^6;
- sbit s2=P2^7;
- uchar con[]={0x7f,0xfe,0xfd, 0xfb,0xf7,0xef,0xdf,0xbf};
- uchar date[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06, 0x5b, 0x4f, 0x66,0x6d,0x7d, 0x07, 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00} ;
- int i,j,k;
- void delay(int i){
- while(i--);
- }
- void main(){
- while(1)
- for(i=0;i<15;i++)
- {
- k=1000;
- while(k--) {
- s1=0; s2=1;
- P0=0xff;
- for(j=0;j<8;j++) {
- s1=0; s2=1;
- P0=con[j];
- delay(50);
- s1=1; s2=0;
- P0=date[i+j];
-
-
- }
- }
- delay(100000);
- }
- }
复制代码
|