疑似版主OYL第一个单片机实物16x16点阵
转载疑似小编OYL的帖子,请见谅:
这是我做的第一个实物,计划是一周做完的,结果前拖了快一个月。失败了两次,第二块板子焊完失败后有点快崩溃的感觉。走了不少弯路,后来这些经历告诉我,做实物前要好好打算,查好充足的资料在动手。前两次失败最根本的原因是点阵的管脚我误以为是和仿真的一样按顺序的,左边是段选,右边是位选。后来实验室的熊星说不是按顺序的,叫我查下型号。我上网查了一下我点阵的型号SD413788
然后焊第三块板子。
后来的编程,我参照的是别人的程序,发现有问题。我发现595似乎不太听话。而P1口还是很听话的。纠结了几天问了程匹克学长,问是不是硬件问题。我说按行扫描没问题,但是就是有点问题,他说你再按列扫描,如果可以,说明硬件没有问题。
后两天,我就抛弃了仿照别人程序的方法,别人是按行扫描的,我去按列扫描,发现没问题。当时还是8x8,那时我知道,我离做好16x16不远了。嘿嘿
这是后面的线
先显示的是一个字
,后面是一个大字(不要误会其实我姓欧阳)
前天,16x16显示一个字成功了。
然后在论坛上看到别人移动数码管,借鉴一下,我的16x16 也可以移动了。
-
- #include
- sbit SH_CP=P3^3;
- sbit DS =P3^4;
- sbit ST_CP=P3^5;
- void delay(unsigned int n);
- unsigned char code time[]=
- {0xfe,0xfd,0xfb,0xf7,0xef,0xef,0xdf,0xbf,0x7f,0xfe,0xfd,0xfb,0xf7,0xef,0xef,0xdf,0xbf,0x7f
- };
- unsigned char code display[]= {
- 0xFF,0xFF,0xFF,0xFF,0xE0,0x03,0xEF,0xFD,0xE0,0x7E,0xEF,0x9D,0xE1,0xE7,0x0E,0x7B,
- 0xF7,0xBD,0xFB,0xDF,0xF7,0x7F,0xF7,0x7F,0x00,0x00,0xF7,0xBF,0xC3,0x9F,0xFD,0xBF,
- 0xFF,0xFF, 0xFF,0xF0,0xFF,0xFE,0xE0,0x06,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0x00,0x01,
- 0xEE,0xEF,0xEE,0xEF,0xEE,0xEF,0xEE,0xEF,0xE0,0x07,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xFF,0xFB,0xE0,0x03,0xF7,0xFB,0xF7,0xFB,0xFF,0xFF,
- 0xFF,0xFF,0xF8,0x0F,0xF7,0xF7, 0xEF,0xFB, 0xEF,0xFB,0xF7,0xF7,0xF8,0x0F,0xFF,0xFF,
- 0xFF,0xFF,0xF8,0x0F,0xF7,0xF7, 0xEF,0xFB, 0xEF,0xFB,0xF7,0xF7,0xF8,0x0F,0xFF,0xFF,
- 0xFF,0xFF,0xEF,0x8F,0xEF,0x77, 0xEE,0xFB,0xEE,0xFB,0xEF,0x7B,0xE0,0x67,0xFF,0xFF,
- 0xFF,0xFF, 0xDE,0xFB, 0xDE,0xFB,0xC0,0x03,0xDE,0xFB,0xDE,0xFB,0xFF,0xFF,0x00,0x1F,
- 0xFF,0xE7,0xE0,0x7B,0xFF,0xBD,0xDE,0xEE,0xDE,0xEF, 0xC0,0x07,0xDE,0xF3,0xDE,0xF7,
-
- };
- void delay(unsigned int n)
- {
- unsigned int x,y;
- for(x=n;x>0;x--)
- for(y=120;y>0;y--);
- }
- void hc595_senddat(unsigned char dat)
- {
- unsigned char i;
- for(i=0;i<8;i++)
- {
- DS=dat&0x80;
- SH_CP=1;
- SH_CP=0;
- dat<<=1;
- }
- }
- main()
- {
- unsigned int i,m,n;
- SH_CP=0;
- ST_CP=0;
- while(1)
- { for(m=0;m<288;m+=2)
- for(n=0;n<10;n++)//显示速度控制
- for(i=0;i<16;i++)
- {
- P1=~display[m+2*i];
- P2=~display[m+2*i+1];
- if(i<8)
- { hc595_senddat(time[i-6]);hc595_senddat(0xff); }
-
- else
- { hc595_senddat(0xff);hc595_senddat(time[i-6]); }
-
- ST_CP=1;
- ST_CP=0;
- delay(1);
- }
-
- }
- }
这是动态的。
我是个新手我也正准备做一个,
不过看过好多电路图,都没有说明四个点阵之间是怎么样连接的。小编可以告诉我一下吗?谢谢
回沙发:晕死、级联的,亲。
看看
小编,江湖救急啊 ! 我的邮箱,519828247@qq.com
6*16点阵,现象是字移动到一半的点阵就消失了,到另一半点阵又出现了,而不是走完整个点阵?
还有点阵的移动函数怎么理解?希望能举个简单例子,然后详细地讲解,谢谢!
对了,k是第几个字,2个138和2个595
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit r=P2^0;
sbit clk=P2^1;
sbit stb=P2^2;
uchar code table[3][32]={
{0x04,0x80,0x04,0x80,0x08,0x80,0x08,0x80,
0x10,0x84,0x20,0x84,0x40,0x7C,0x80,0x00,
0x00,0x00,0x3F,0xF0,0x02,0x00,0x02,0x00,
0x02,0x00,0x02,0x00,0x7F,0xFC,0x04,0x80,}, //无
{0x40,0x44,0xFC,0x48,0x40,0x30,0x00,0x22,
0x1C,0x52,0xE0,0x8A,0x43,0x06,0x00,0x02,
0x10,0x50,0x10,0x48,0x20,0x40,0x24,0x5C, // 线
0x45,0xE0,0xF8,0x40,0x10,0x5E,0x23,0xE0,},
{0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,
0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE,
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,
0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,}
};
void writebyte(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
dat=dat>>1;
r=CY;
clk=0;
clk=1;
}
}
void senddata()
{
stb=0;
stb=1;
}
void main()
{
uchar num,i,j,k;
while(1)
{
for(k=1;k<3;k++)
{
for(i=0;i<16;i++) //移动一个字
{
for(j=0;j<20;j++)
{
for(num=0;num<16;num++) //移动一位
{
if(i<8)
{
writebyte(((table[k][2*num]>>(8-i))|(table[k][2*num+1]<<i)));
writebyte(((table[k-1][2*num+1]>>(8-i))|(table[k-1][2*num]<<i)));
senddata();
}
else
{
writebyte(((table[k][2*num+1]>>(16-i))|(table[k][2*num]<<(i-8))));
writebyte(((table[k-1][2*num]>>(16-i))|(table[k-1][2*num+1]<<(i-8))));
senddata();
}
P1=num;
}
}
}
}
}
}