搜索
bottom↓
回复: 2

20X7微型点阵屏,可切换字体。

[复制链接]

出0入0汤圆

发表于 2012-4-11 13:15:33 | 显示全部楼层 |阅读模式
本帖最后由 oufuqiang 于 2012-4-11 13:19 编辑

20X7微型点阵屏,可切换字体。 595控制的。

http://v.youku.com/v_show/id_XMzc5NDMyNDI0.html


  1. #include <reg52.h>

  2. sbit scl = P1^0;
  3. sbit sda = P1^1;
  4. sbit upd = P1^2;
  5. sbit dpy = P1^7;

  6. sbit key1 = P2^0;
  7. sbit key2 = P2^1;
  8. sbit key3 = P2^2;
  9. sbit key4 = P2^4;
  10. sbit key5 = P2^5;

  11. unsigned char line,c1,c2,c3,c4;
  12. unsigned char code scantab[5]={0x02,0x04,0x08,0x10,0x20};
  13. bit charface,dot;
  14. unsigned char code numdot1[]={
  15. 0x00,0x60,0xFA,0x60,0x00,0x08,0x70,0x08,0x70,0x00,0x28,0x7C,0x28,0x7C,0x28,0x20,
  16. 0x54,0xFE,0x54,0x08,0x64,0x68,0x10,0x2C,0x4C,0x1C,0x62,0xBA,0x64,0x3A,0x00,0x02,
  17. 0x0C,0x00,0x00,0x00,0x38,0x44,0x82,0x00,0x82,0x44,0x38,0x00,0x00,0x48,0x30,0xFC,
  18. 0x30,0x48,0x00,0x10,0x7C,0x10,0x00,0x00,0x02,0x0C,0x00,0x00,0x00,0x08,0x08,0x08,
  19. 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x1C,0x60,0x80,0x00,0x7C,0x92,0xA2,0x7C,
  20. 0x00,0x42,0xFE,0x02,0x00,0x00,0x66,0x8A,0x92,0x62,0x00,0x44,0x92,0x92,0x6C,0x00,
  21. 0x38,0x4A,0xFE,0x0A,0x00,0xE4,0x92,0x92,0x8C,0x00,0x7C,0x92,0x92,0x0C,0x00,0xC0,
  22. 0x9E,0xA0,0xC0,0x00,0x6C,0x92,0x92,0x6C,0x00,0x60,0x92,0x92,0x7C,0x00,0x00,0x44,
  23. 0x00,0x00,0x00,0x02,0x4C,0x00,0x00,0x10,0x28,0x44,0x82,0x00,0x00,0x24,0x24,0x24,
  24. 0x24,0x00,0x82,0x44,0x28,0x10,0x00,0x60,0x8A,0x90,0x60,0x7C,0x82,0x9A,0xAA,0x7A,
  25. 0x00,0x3E,0xC8,0x78,0x0E,0x00,0x82,0xFE,0x92,0x6C,0x00,0x7C,0x82,0x82,0x44,0x00,
  26. 0x82,0xFE,0x82,0x7C,0x00,0xFE,0x92,0x92,0x82,0x00,0xFE,0x90,0x90,0x80,0x00,0x7C,
  27. 0x82,0x8A,0x4C,0x00,0xFE,0x10,0x10,0xFE,0x00,0x82,0xFE,0x82,0x00,0x00,0x06,0x82,
  28. 0xFC,0x80,0x00,0xFE,0x10,0x28,0x44,0x00,0xFE,0x02,0x02,0x02,0xFE,0xF0,0x0E,0xF0,
  29. 0xFE,0xFE,0x20,0x10,0x08,0xFE,0x00,0x7C,0x82,0x82,0x7C,0x00,0xFE,0x88,0x88,0x70,
  30. 0x00,0x7C,0x82,0x84,0x7A,0x00,0xFE,0x90,0x98,0x66,0x00,0x64,0x92,0x92,0x4C,0x80,
  31. 0x80,0xFE,0x80,0x80,0x00,0xFC,0x02,0x02,0xFC,0x00,0xF8,0x06,0x1C,0xE0,0xE0,0x1E,
  32. 0xF0,0x1E,0xE0,0x82,0x6C,0x10,0x6C,0x82,0x80,0xE2,0x1E,0xE2,0x80,0x00,0x00,0x8E,
  33. 0x92,0xE2};
  34. unsigned char code numdot2[]={
  35. 0x00,0x60,0xFA,0x60,0x00,0x08,0x70,0x08,0x70,0x00,0x28,0x7C,0x28,0x7C,0x28,0x20,
  36. 0x54,0xFE,0x54,0x08,0x64,0x68,0x10,0x2C,0x4C,0x1C,0x62,0xBA,0x64,0x3A,0x00,0x02,
  37. 0x0C,0x00,0x00,0x00,0x38,0x44,0x82,0x00,0x82,0x44,0x38,0x00,0x00,0x48,0x30,0xFC,
  38. 0x30,0x48,0x00,0x10,0x7C,0x10,0x00,0x00,0x02,0x0C,0x00,0x00,0x00,0x08,0x08,0x08,
  39. 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x1C,0x60,0x80,0x00,0xFE,0x82,0x82,0xFE,
  40. 0x00,0x00,0x00,0x00,0xFE,0x00,0x9E,0x92,0x92,0xF2,0x00,0x92,0x92,0x92,0xFE,0x00,
  41. 0xF0,0x10,0x10,0xFE,0x00,0xF2,0x92,0x92,0x9E,0x00,0xFE,0x92,0x92,0x9E,0x00,0xE0,
  42. 0x80,0x80,0xFE,0x00,0xFE,0x92,0x92,0xFE,0x00,0xF2,0x92,0x92,0xFE,0x00,0x00,0x44,
  43. 0x00,0x00,0x00,0x02,0x4C,0x00,0x00,0x10,0x28,0x44,0x82,0x00,0x00,0x24,0x24,0x24,
  44. 0x24,0x00,0x82,0x44,0x28,0x10,0x00,0x60,0x8A,0x90,0x60,0x7C,0x82,0x9A,0xAA,0x7A,
  45. 0x00,0x3E,0xC8,0x78,0x0E,0x00,0x82,0xFE,0x92,0x6C,0x00,0x7C,0x82,0x82,0x44,0x00,
  46. 0x82,0xFE,0x82,0x7C,0x00,0xFE,0x92,0x92,0x82,0x00,0xFE,0x90,0x90,0x80,0x00,0x7C,
  47. 0x82,0x8A,0x4C,0x00,0xFE,0x10,0x10,0xFE,0x00,0x82,0xFE,0x82,0x00,0x00,0x06,0x82,
  48. 0xFC,0x80,0x00,0xFE,0x10,0x28,0x44,0x00,0xFE,0x02,0x02,0x02,0xFE,0xF0,0x0E,0xF0,
  49. 0xFE,0xFE,0x20,0x10,0x08,0xFE,0x00,0x7C,0x82,0x82,0x7C,0x00,0xFE,0x88,0x88,0x70,
  50. 0x00,0x7C,0x82,0x84,0x7A,0x00,0xFE,0x90,0x98,0x66,0x00,0x64,0x92,0x92,0x4C,0x80,
  51. 0x80,0xFE,0x80,0x80,0x00,0xFC,0x02,0x02,0xFC,0x00,0xF8,0x06,0x1C,0xE0,0xE0,0x1E,
  52. 0xF0,0x1E,0xE0,0x82,0x6C,0x10,0x6C,0x82,0x80,0xE2,0x1E,0xE2,0x80,0x00,0x00,0x8E,
  53. 0x92,0xE2};

  54. //void yanshi(unsigned int time)
  55. // {
  56. // while(--time);
  57. // }
  58. void send595(unsigned char dat)
  59.   {
  60.   unsigned char i;
  61.   i=8;
  62.   do{
  63.         sda=dat&0x01;
  64.         scl=1;
  65.         scl=0;
  66.         dat=dat>>1;
  67.         }while(--i);
  68.   }
  69. void scandot(void)
  70.   {
  71.   if(charface)
  72.     {
  73.         send595(numdot1[c1*5+line]);
  74.         send595(numdot1[c2*5+line]);
  75.         send595(numdot1[c3*5+line]|dot);
  76.         send595(numdot1[c4*5+line]);
  77.         }
  78.   else
  79.     {
  80.         send595(numdot2[c1*5+line]);
  81.         send595(numdot2[c2*5+line]);
  82.         send595(numdot2[c3*5+line]|dot);
  83.         send595(numdot2[c4*5+line]);
  84.         }
  85.   send595(scantab[line]);
  86.   upd=1;
  87.   upd=0;
  88.   line++;
  89.   if(line>=5)
  90.     {
  91.     line=0;
  92.     }
  93.   }
  94. void main(void)
  95. {
  96.   TMOD=0X01;
  97.   TR0=1;
  98.   EA=1;
  99.   ET0=1;
  100.   scl=sda=upd=0;
  101.   c1=c2=c3=c4=15;
  102.   send595(0xFF);
  103.   send595(0xFF);
  104.   send595(0xFF);
  105.   send595(0xFF);
  106.   send595(0xFF);
  107.   upd=1;
  108.   upd=0;
  109.   while(key5);
  110. while(1)
  111.   {
  112.   scandot();
  113.   if(key1==0)
  114.     {
  115.         c4++;
  116.         if(c4>=25){c4=15;}
  117.         while(key1==0)
  118.           {
  119.           scandot();
  120.           }
  121.     }
  122.   if(key2==0)
  123.     {
  124.         c3++;
  125.         if(c3>=25){c3=15;}
  126.         while(key2==0)
  127.           {
  128.           scandot();
  129.           }
  130.     }
  131.   if(key3==0)
  132.     {
  133.         c2++;
  134.         if(c2>=25){c2=15;}
  135.         while(key3==0)
  136.           {
  137.           scandot();
  138.           }
  139.     }
  140.   if(key4==0)
  141.     {
  142.         c1++;
  143.         if(c1>=25){c1=15;}
  144.         while(key4==0)
  145.           {
  146.           scandot();
  147.           }
  148.     }
  149.   if(key5==0)
  150.     {
  151.         charface=!charface;
  152.         while(key5==0)
  153.           {
  154.           scandot();
  155.           }
  156.         }
  157.   }
  158. }

  159. void timer0(void) interrupt 1
  160. {
  161. static count,sec;
  162. TH0=(65536-49990)/256;
  163. TL0=(65536-49990)%256;
  164. count++;
  165. if(count>=40)
  166.   {
  167.   count=0;
  168.   dot=!dot;
  169.   sec++;
  170.   if(sec>=60)
  171.     {
  172.         sec=0;
  173.         c1++;
  174.         if(c1>=25)
  175.           {
  176.           c1=15;
  177.           c2++;
  178.           if(c2>=21)
  179.             {
  180.                 c2=15;
  181.                 c3++;
  182.                 if(c3>=25)
  183.                   {
  184.                   c3=15;
  185.                   c4++;
  186.                   if(c4>=21)
  187.                     {
  188.                         c1=c2=c3=c4=15;
  189.                         }
  190.                   }
  191.                 }
  192.           }
  193.         }
  194.   }
  195. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入0汤圆

发表于 2012-4-11 14:02:15 | 显示全部楼层
不错,谢谢楼主分享,能不能把SER全部接在一起,再用上片选

出0入0汤圆

发表于 2012-4-11 17:05:45 | 显示全部楼层
不错不错,这种小点阵貌似我公司有,有空做来玩玩
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-20 03:26

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表