自己实训做的,不知道有没有不足的地方,希望指导一下
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include "reg51.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define Lie P1
- sbit SHCP = P2^0;
- sbit DS = P2^1;
- sbit STCP = P2^2;
- uchar code led[ ] ={
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFE,0xFF,0x22,0x04,0x5A,0x08,0x86,0x07,0x08,0x20,0x88,0x11,0x68,0x0D,
- 0x18,0x41,0x0F,0x81,0xE8,0x7F,0x08,0x01,0x08,0x05,0x08,0x09,0x08,0x30,0x00,0x00, // 陈
- 0x00,0x40,0x00,0x38,0xFC,0x00,0x44,0x00,0x44,0x3C,0x44,0x40,0x44,0x40,0xFF,0x43,
- 0x44,0x4C,0x44,0x40,0x44,0x40,0x44,0x70,0xFC,0x04,0x00,0x08,0x00,0x30,0x00,0x00, //忠
- 0x20,0x04,0x10,0x04,0x08,0x04,0xFC,0x05,0x03,0x04,0x20,0x04,0x20,0x04,0x10,0xFF,
- 0x7F,0x04,0x88,0x04,0x88,0x04,0x84,0x04,0x82,0x04,0xE0,0x04,0x00,0x04,0x00,0x00, //华
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- //uchar led[]={}
- void shift16bit(uchar dat1,uchar dat2) //595输出16位数据
- {
- uchar i;
- STCP=0;
- for(i=0;i<8;i++)
- {
- SHCP=0;
- if(dat1 &0x80) DS=1;
- else DS=0;
- dat1<<=1;
- SHCP=1;
- }
- for(i=0;i<8;i++)
- {
- SHCP=0;
- if(dat2 &0x80) DS=1;
- else DS=0;
- dat2<<=1;
- SHCP=1;
- }
- STCP=1;
- }
- void delay(uint x)
- {
- uint i;
- for(i=0;i<x;i++);
- }
- void main()
- {
- uchar i,x=0;
- uint n;
-
- while(1)
- {
- for(n=0;n<10;n++)
- for(i=0;i<16;i++)
- {
- Lie=i;
- shift16bit(led[2*i+1+2*x],led[2*i+2*x]);
- delay(10);
- }
- x++;
- if(x==48) x=0;
- /*
- for(n=0;n<100;n++)
- for(i=0;i<16;i++)
- {
- Lie= i;
- shift16bit(led[x][2*i+1],led[x][2*i]);
- delay(100);
- }
- x++;
- if(x==4) x=0;
- */
- }
- }
复制代码
所有资料51hei提供下载:
163110109 16x16 点阵显示姓名陈忠华.rar
(92.28 KB, 下载次数: 158)
|