本帖最后由 oufuqiang 于 2012-4-11 13:19 编辑
20X7微型点阵屏,可切换字体。 595控制的。
http://v.youku.com/v_show/id_XMzc5NDMyNDI0.html
IMG_0594.jpg (750.83 KB, 下载次数: 0)
下载附件
2012-4-11 13:18 上传
- #include <reg52.h>
- sbit scl = P1^0;
- sbit sda = P1^1;
- sbit upd = P1^2;
- sbit dpy = P1^7;
- sbit key1 = P2^0;
- sbit key2 = P2^1;
- sbit key3 = P2^2;
- sbit key4 = P2^4;
- sbit key5 = P2^5;
- unsigned char line,c1,c2,c3,c4;
- unsigned char code scantab[5]={0x02,0x04,0x08,0x10,0x20};
- bit charface,dot;
- unsigned char code numdot1[]={
- 0x00,0x60,0xFA,0x60,0x00,0x08,0x70,0x08,0x70,0x00,0x28,0x7C,0x28,0x7C,0x28,0x20,
- 0x54,0xFE,0x54,0x08,0x64,0x68,0x10,0x2C,0x4C,0x1C,0x62,0xBA,0x64,0x3A,0x00,0x02,
- 0x0C,0x00,0x00,0x00,0x38,0x44,0x82,0x00,0x82,0x44,0x38,0x00,0x00,0x48,0x30,0xFC,
- 0x30,0x48,0x00,0x10,0x7C,0x10,0x00,0x00,0x02,0x0C,0x00,0x00,0x00,0x08,0x08,0x08,
- 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x1C,0x60,0x80,0x00,0x7C,0x92,0xA2,0x7C,
- 0x00,0x42,0xFE,0x02,0x00,0x00,0x66,0x8A,0x92,0x62,0x00,0x44,0x92,0x92,0x6C,0x00,
- 0x38,0x4A,0xFE,0x0A,0x00,0xE4,0x92,0x92,0x8C,0x00,0x7C,0x92,0x92,0x0C,0x00,0xC0,
- 0x9E,0xA0,0xC0,0x00,0x6C,0x92,0x92,0x6C,0x00,0x60,0x92,0x92,0x7C,0x00,0x00,0x44,
- 0x00,0x00,0x00,0x02,0x4C,0x00,0x00,0x10,0x28,0x44,0x82,0x00,0x00,0x24,0x24,0x24,
- 0x24,0x00,0x82,0x44,0x28,0x10,0x00,0x60,0x8A,0x90,0x60,0x7C,0x82,0x9A,0xAA,0x7A,
- 0x00,0x3E,0xC8,0x78,0x0E,0x00,0x82,0xFE,0x92,0x6C,0x00,0x7C,0x82,0x82,0x44,0x00,
- 0x82,0xFE,0x82,0x7C,0x00,0xFE,0x92,0x92,0x82,0x00,0xFE,0x90,0x90,0x80,0x00,0x7C,
- 0x82,0x8A,0x4C,0x00,0xFE,0x10,0x10,0xFE,0x00,0x82,0xFE,0x82,0x00,0x00,0x06,0x82,
- 0xFC,0x80,0x00,0xFE,0x10,0x28,0x44,0x00,0xFE,0x02,0x02,0x02,0xFE,0xF0,0x0E,0xF0,
- 0xFE,0xFE,0x20,0x10,0x08,0xFE,0x00,0x7C,0x82,0x82,0x7C,0x00,0xFE,0x88,0x88,0x70,
- 0x00,0x7C,0x82,0x84,0x7A,0x00,0xFE,0x90,0x98,0x66,0x00,0x64,0x92,0x92,0x4C,0x80,
- 0x80,0xFE,0x80,0x80,0x00,0xFC,0x02,0x02,0xFC,0x00,0xF8,0x06,0x1C,0xE0,0xE0,0x1E,
- 0xF0,0x1E,0xE0,0x82,0x6C,0x10,0x6C,0x82,0x80,0xE2,0x1E,0xE2,0x80,0x00,0x00,0x8E,
- 0x92,0xE2};
- unsigned char code numdot2[]={
- 0x00,0x60,0xFA,0x60,0x00,0x08,0x70,0x08,0x70,0x00,0x28,0x7C,0x28,0x7C,0x28,0x20,
- 0x54,0xFE,0x54,0x08,0x64,0x68,0x10,0x2C,0x4C,0x1C,0x62,0xBA,0x64,0x3A,0x00,0x02,
- 0x0C,0x00,0x00,0x00,0x38,0x44,0x82,0x00,0x82,0x44,0x38,0x00,0x00,0x48,0x30,0xFC,
- 0x30,0x48,0x00,0x10,0x7C,0x10,0x00,0x00,0x02,0x0C,0x00,0x00,0x00,0x08,0x08,0x08,
- 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x1C,0x60,0x80,0x00,0xFE,0x82,0x82,0xFE,
- 0x00,0x00,0x00,0x00,0xFE,0x00,0x9E,0x92,0x92,0xF2,0x00,0x92,0x92,0x92,0xFE,0x00,
- 0xF0,0x10,0x10,0xFE,0x00,0xF2,0x92,0x92,0x9E,0x00,0xFE,0x92,0x92,0x9E,0x00,0xE0,
- 0x80,0x80,0xFE,0x00,0xFE,0x92,0x92,0xFE,0x00,0xF2,0x92,0x92,0xFE,0x00,0x00,0x44,
- 0x00,0x00,0x00,0x02,0x4C,0x00,0x00,0x10,0x28,0x44,0x82,0x00,0x00,0x24,0x24,0x24,
- 0x24,0x00,0x82,0x44,0x28,0x10,0x00,0x60,0x8A,0x90,0x60,0x7C,0x82,0x9A,0xAA,0x7A,
- 0x00,0x3E,0xC8,0x78,0x0E,0x00,0x82,0xFE,0x92,0x6C,0x00,0x7C,0x82,0x82,0x44,0x00,
- 0x82,0xFE,0x82,0x7C,0x00,0xFE,0x92,0x92,0x82,0x00,0xFE,0x90,0x90,0x80,0x00,0x7C,
- 0x82,0x8A,0x4C,0x00,0xFE,0x10,0x10,0xFE,0x00,0x82,0xFE,0x82,0x00,0x00,0x06,0x82,
- 0xFC,0x80,0x00,0xFE,0x10,0x28,0x44,0x00,0xFE,0x02,0x02,0x02,0xFE,0xF0,0x0E,0xF0,
- 0xFE,0xFE,0x20,0x10,0x08,0xFE,0x00,0x7C,0x82,0x82,0x7C,0x00,0xFE,0x88,0x88,0x70,
- 0x00,0x7C,0x82,0x84,0x7A,0x00,0xFE,0x90,0x98,0x66,0x00,0x64,0x92,0x92,0x4C,0x80,
- 0x80,0xFE,0x80,0x80,0x00,0xFC,0x02,0x02,0xFC,0x00,0xF8,0x06,0x1C,0xE0,0xE0,0x1E,
- 0xF0,0x1E,0xE0,0x82,0x6C,0x10,0x6C,0x82,0x80,0xE2,0x1E,0xE2,0x80,0x00,0x00,0x8E,
- 0x92,0xE2};
- //void yanshi(unsigned int time)
- // {
- // while(--time);
- // }
- void send595(unsigned char dat)
- {
- unsigned char i;
- i=8;
- do{
- sda=dat&0x01;
- scl=1;
- scl=0;
- dat=dat>>1;
- }while(--i);
- }
- void scandot(void)
- {
- if(charface)
- {
- send595(numdot1[c1*5+line]);
- send595(numdot1[c2*5+line]);
- send595(numdot1[c3*5+line]|dot);
- send595(numdot1[c4*5+line]);
- }
- else
- {
- send595(numdot2[c1*5+line]);
- send595(numdot2[c2*5+line]);
- send595(numdot2[c3*5+line]|dot);
- send595(numdot2[c4*5+line]);
- }
- send595(scantab[line]);
- upd=1;
- upd=0;
- line++;
- if(line>=5)
- {
- line=0;
- }
- }
- void main(void)
- {
- TMOD=0X01;
- TR0=1;
- EA=1;
- ET0=1;
- scl=sda=upd=0;
- c1=c2=c3=c4=15;
- send595(0xFF);
- send595(0xFF);
- send595(0xFF);
- send595(0xFF);
- send595(0xFF);
- upd=1;
- upd=0;
- while(key5);
- while(1)
- {
- scandot();
- if(key1==0)
- {
- c4++;
- if(c4>=25){c4=15;}
- while(key1==0)
- {
- scandot();
- }
- }
- if(key2==0)
- {
- c3++;
- if(c3>=25){c3=15;}
- while(key2==0)
- {
- scandot();
- }
- }
- if(key3==0)
- {
- c2++;
- if(c2>=25){c2=15;}
- while(key3==0)
- {
- scandot();
- }
- }
- if(key4==0)
- {
- c1++;
- if(c1>=25){c1=15;}
- while(key4==0)
- {
- scandot();
- }
- }
- if(key5==0)
- {
- charface=!charface;
- while(key5==0)
- {
- scandot();
- }
- }
- }
- }
- void timer0(void) interrupt 1
- {
- static count,sec;
- TH0=(65536-49990)/256;
- TL0=(65536-49990)%256;
- count++;
- if(count>=40)
- {
- count=0;
- dot=!dot;
- sec++;
- if(sec>=60)
- {
- sec=0;
- c1++;
- if(c1>=25)
- {
- c1=15;
- c2++;
- if(c2>=21)
- {
- c2=15;
- c3++;
- if(c3>=25)
- {
- c3=15;
- c4++;
- if(c4>=21)
- {
- c1=c2=c3=c4=15;
- }
- }
- }
- }
- }
- }
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>