keilc实验作业——基于c51的点阵LED显示实验
标准答案分享
供实验课同学下载
单片机源程序:
- #include<reg51.h>
- #define uint unsigned int
- #define uchar unsigned char
- const uchar tab[][8]={
- 0x3c,0x66,0x6e,0x6e,0x76,0x76,0x66,0x3c,
- 0x18,0x78,0x18,0x18,0x18,0x18,0x18,0x7e,
- 0x3c,0x66,0x66,0x06,0x1c,0x30,0x66,0x7e,
- 0x3c,0x66,0x06,0x1c,0x06,0x66,0x66,0x3c,
- 0x1c,0x3c,0x6c,0xcc,0xcc,0xfe,0x0c,0x0c,
- 0x7e,0x60,0x7c,0x66,0x06,0x06,0x66,0x3c,
- 0x1c,0x30,0x60,0x7c,0x66,0x66,0x66,0x3c,
- 0x7e,0x66,0x06,0x0c,0x08,0x18,0x30,0x30,
- 0x3c,0x66,0x66,0x3c,0x66,0x66,0x66,0x3c,
- 0x3c,0x66,0x66,0x66,0x3e,0x06,0x0c,0x38,
- };
- void delay(uchar x)
- {
- uint i;
- while((x--)!=0)
- {
- for(i=0;i<125;i++)
- {;}
- }
- }
- void main(void)
- {
- uchar i,j,k,m,n,p,q;
- while(1)
- {
- for(j=0;j<10;j++)
- {
- for(q=0;q<8;q++)
- {
- for(k=0;k<15;k++)
- {
- m=0x80;
- for(i=0;i<15;i++)
- {
- P3=~m;
- n=tab[j][i];
- n=(n<<q);
- if(j==9)
- p=tab[0][i];
- else
- p=tab[j+1][i];
- p=(p>>8-q);
- n=n|p;
- P2=n;
- delay(1);
- m=(m>>1);
- }
- }
- }
-
- }
- }
- }
复制代码
所有资料下载:
实验二-数字显示.zip
(51.97 KB, 下载次数: 12)
|