数码管显示学号仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<reg52.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- char code shu[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
- char code num[16][8]={0Xff,0Xff,0Xff,0Xff,0Xff,0Xff,0Xff,0Xa4,
- 0Xff,0Xff,0Xff,0Xff,0Xff,0Xff,0Xa4,0xc0,
- 0Xff,0Xff,0Xff,0Xff,0Xff,0xa4,0xc0,0xf9,
- 0Xff,0Xff,0Xff,0Xff,0xa4,0xc0,0xf9,0x92,
- 0Xff,0Xff,0Xff,0xa4,0xc0,0xf9,0x92,0xf9,
- 0Xff,0Xff,0xa4,0xc0,0xf9,0x92,0xf9,0xf9,
- 0Xff,0xa4,0xc0,0xf9,0x92,0xf9,0xf9,0xf9,
- 0xa4,0xc0,0xf9,0x92,0xf9,0xf9,0xf9,0x80,
- 0xc0,0xf9,0x92,0xf9,0xf9,0xf9,0x80,0xff,
- 0xf9,0x92,0xf9,0xf9,0xf9,0x80,0xff,0xff,
- 0x92,0xf9,0xf9,0xf9,0x80,0xff,0xff,0xff,
- 0xf9,0xf9,0xf9,0x80,0xff,0xff,0xff,0xff,
- 0xf9,0xf9,0x80,0xff,0xff,0xff,0xff,0xff,
- 0xf9,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
- char code wei1[]={0X80,0X40,0X20,0X10,0X08,0X04,0X02,0X01} ;
- char code wei2[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80} ;
- uchar t,i,n,m,j,temp;
- sbit led1=P3^6;
- void delay_AUS(uint z)
- {
- while(t!=z);
- t=0;
- }
- void delay(uint z)
- {
- int x,y;
- for(x=z;x>0;x--)
- {
- for(y=100;y>0;y--);
- }
- }
- void main()
- {
- t=0;
- TMOD=0x01;
- TH0=(65536-50000)/256;//timer 50ms
- TL0=(65536-50000)%256;
- EA=1;
- ET0=1;
- TR0=1;
-
- while(1)
- { for(n=0;n<3;n++)
- { for(i=0;i<16;i++)
- {
- for(temp=0;temp<31;temp++)
- {
- for(j=0;j<8;j++)
- {
- P0=num[i][j];
- P2=wei2[j];
- delay(2);
- P0=0xff;
- }
- }
- delay_AUS(20);
- }
- }
- for(m=0;m<10000;m++)
- {for(j=0;j<8;j++)
- {
- P0=num[7][j];
- P2=wei2[j];
- delay(2);
- P0=0xff;
- }
- }
- }
- }
- void timer0() interrupt 1
- {
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- t++;
- }
复制代码
所有资料51hei提供下载:
学号显示20151126.zip
(77.52 KB, 下载次数: 26)
|