之前画的板子早到手了,程序写好也能烧,使用正常,芯片用的是STC15F2K60S2,52的增强版,程序通用但有略微不同。系统性学了一遍51后又回头把程序改的更规范一点,程序里有注释,protuse的源文件看不了的话可以找我的第一篇帖子,里面也有原理图,不过有略微改动,以程序里的定义为准。
可以实现横向滚屏,用取模软件按图设置选项取模就好,滚屏速度按照程序里的提示改就好。
实物图:
实物图
取模软件的设置如下:
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include <reg51.h>
- #include<intrins.h>
- typedef unsigned int u16;
- typedef unsigned char u8;
- #define CS P1 //位选
- sbit IO_1 =P0^0; //数据发送
- sbit CLK_1 =P0^1; //移位时钟
- sbit Sent_1=P0^2; //并行发送时钟
- sbit IO_2 =P0^3;
- sbit CLK_2 =P0^4;
- sbit Sent_2=P0^5;
- void dispiay();
- u8 code ledduan[]={
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x20,0x00,0x38,0x00,0x18,0x3E,0xEA,0x3E,0xEE,0x02,0xAC,0x02,0xA8,0x02,0xAF,0xFF,
- 0xAF,0xFF,0xA8,0x02,0xAC,0x12,0xEE,0x32,0xEA,0x3E,0x28,0x1E,0x38,0x00,0x18,0x00,/*"常",0*/
- 0x00,0x81,0xE0,0xC1,0xE0,0x70,0xFF,0x3F,0xFF,0x0F,0x20,0x00,0xE0,0x00,0xC0,0x00,
- 0xFE,0x3F,0xFE,0x3F,0x20,0x00,0xE0,0x00,0xC0,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,/*"州",1*/
- 0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,
- 0xFC,0x3F,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,/*"工",2*/
- 0x40,0x04,0x70,0x04,0x31,0x04,0x97,0x04,0x96,0x04,0x90,0x44,0x91,0xC4,0x97,0xFE,
- 0x96,0x7E,0x90,0x07,0x98,0x05,0x9C,0x04,0x17,0x04,0x53,0x04,0x70,0x04,0x30,0x04,/*"学",3*/
- 0x00,0x00,0xFE,0xFF,0xFE,0xFF,0x7A,0x0C,0xDE,0x0F,0x96,0x87,0x1C,0xC1,0x2C,0x71,
- 0x24,0x3F,0x25,0x0F,0x27,0x01,0x26,0x3F,0x24,0x7F,0x34,0x41,0x1C,0x71,0x0C,0x71,/*"院",4*/
- 0xF0,0x01,0xF8,0x03,0xFC,0x0F,0xFC,0x1F,0xFC,0x3F,0xF8,0x7F,0xF8,0x7F,0xF0,0xFF,
- 0xF0,0xFF,0xF8,0x7F,0xF8,0x7F,0xFC,0x3F,0xFC,0x1F,0xFC,0x0F,0xF8,0x03,0xF0,0x01,//爱心
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
- u8 ledwei[]={
- 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
- 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F
- };
- void main()
- {
- CS=0;
- while(1)
- {
- dispiay();
- }
- }
- void sendby1(unsigned char dat)
- {
- u8 mask;
- CLK_1=0;
- Sent_1=0;
- for (mask=0x80;mask!=0;mask>>=1)
- {
- if((mask&dat)!=0)
- IO_1=1;
- else
- IO_1=0;
- CLK_1=1;
- _nop_();
- _nop_();
- CLK_1=0;
- }
- Sent_1=1;
- _nop_();
- _nop_();
- Sent_1=0;
- }
- void sendby2(unsigned char dat)
- {
- u8 mask;
- CLK_2=0;
- Sent_2=0;
- for (mask=0x80;mask!=0;mask>>=1)
- {
- if((mask&dat)!=0)
- IO_2=1;
- else
- IO_2=0;
- CLK_2=1; //时钟脉冲,移位
- _nop_();
- _nop_();
- CLK_2=0;
- }
- Sent_2=1; //8位串行发送完毕,并行输出时钟输出
- _nop_();
- _nop_();
- Sent_2=0;
- }
- void dispiay()
- {
- static u8 cont=0;
- static u16 incres=0;
- u8 i=0;
- u8 index=0;
- for(i=0;i<16;i++) //发送一帧图像
- {
- sendby1(0x00);
- sendby2(0x00);
- CS=ledwei[i];
- sendby1(ledduan[index+incres]);
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
16点阵滚屏.zip
(2.93 MB, 下载次数: 28)
|