找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 8408|回复: 11
收起左侧

16*16滚动点阵屏+音乐盒C语言源程序

  [复制链接]
ID:83710 发表于 2015-6-25 21:56 | 显示全部楼层 |阅读模式
   这个东西是09年刚学单片机时做的,基于51单片机。点阵屏用的是一个集成好的模块,就是四个595两两级联分别控制行和列,屏可能有点老,所以不是很亮。字摸直接用网上的字摸提取软件就能提取。另外用定时计数器产生方波做了一个音乐播放器(用了一个运放),放的是天空之城的音乐,同时用一个两位数码管显示当前的音乐音阶(第一位数码管表示高中低音)。感觉里面用了不少51的资源,挺好的程序,现在完全开源的给大家分享出来

作品图片:
  1. #include<reg51.h>
  2. sbit RCK=P2^2;
  3. sbit SRCK_1=P2^3;
  4. sbit SRCK_2=P2^4;
  5. sbit SER_IN_1=P2^5;
  6. sbit SER_IN_2=P2^6;
  7. sbit DIG1=P2^0;
  8. sbit DIG2=P2^1;
  9. sbit buz=P2^7;
  10. unsigned char num=13;--字幕有多少个字

  11. unsigned int speed=85;--每状态持续时间,数字越小,字幕速度越快

  12. unsigned int  song_num=136;--音节个数


  13. unsigned char code song[]=--中音前缀为1,低音为0,高音为2+后位为歌谱
  14. {
  15.   16,17,21,17,21,23,17,13,13,16,15,16,21,15,10,13,13,14,13,14,21,
  16.   10,13,01,21,21,21,17,14,14,17,17,10,16,17,21,17,21,23,17,10,13,13,16,15,16,21,
  17.   15,10,13,14,21,17,17,21,22,22,23,21,10,21,17,16,16,17,15,16,10,21,22,23,22,23,
  18.   25,22,10,15,15,21,17,21,23,23,10,10,16,17,21,17,22,22,21,15,15,10,24,23,22,21,
  19.   23,23,10,23,26,25,25,23,22,21,10,21,22,21,22,22,25,23,10,23,26,25,23,22,21,10,
  20.   21,22,21,22,22,17,16,10,16,17,16
  21. };


  22. unsigned char code song_speed[]=--节拍,数目越大声音持续时间越长,与各曲谱位置对应
  23. {
  24.   40,60,120,80,100,100,300,40,60,120,80,100,100,200,100,50,50,120,80,80,120,100,200,25,25,
  25.   25,25,120,80,105,95,200,100,50,50,120,80,100,100,200,100,50,50,120,80,100,100,300,50,50,
  26.   100,40,50,110,100,33,33,33,100,100,120,80,50,50,100,100,200,100,50,50,120,80,100,100,
  27.   200,100,50,50,110,90,100,100,200,100,100,45,55,100,100,50,50,110,80,110,100,100,100,100,100,
  28.   400,200,100,100,200,100,100,50,50,100,50,50,100,45,55,100,100,200,100,100,200,200,120,80,
  29.   200,50,50,100,60,40,50,100,200,100,50,50,400
  30. };


  31. unsigned char code hanzi[]=--字模提取BADC,右旋90度
  32. {
  33. 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0xFF,0x80,0x40,0x80,0x40,0xA0,0x23,--长
  34. 0x90,0x04,0x88,0x08,0x84,0x10,0x86,0x20,0x80,0x60,0xC0,0x20,0x80,0x00,0x00,0x00,

  35. 0x20,0x04,0x22,0x04,0x2A,0x02,0x2A,0x01,0xAA,0xFF,0x6A,0x49,0x3A,0x49,0x2F,0x49,--春
  36. 0x2A,0x49,0x6A,0x49,0xAA,0xFF,0x2A,0x01,0x2A,0x02,0x22,0x06,0x20,0x02,0x00,0x00,

  37. 0x44,0x10,0x44,0x30,0xFC,0x1F,0x46,0x08,0x44,0x48,0x00,0x48,0xFE,0x44,0x92,0x44,--理
  38. 0x92,0x44,0xFE,0x7F,0x92,0x44,0x92,0x46,0xFF,0x44,0x02,0x60,0x00,0x40,0x00,0x00,

  39. 0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,--工
  40. 0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x06,0x20,0x04,0x30,0x00,0x20,0x00,0x00,

  41. 0x80,0x00,0x80,0x40,0x40,0x40,0x20,0x4A,0x50,0x52,0x48,0x62,0x44,0x42,0xC3,0x7F,--姓   0x44,0x42,0x68,0x62,0x50,0x52,0x20,0x4A,0x40,0x60,0xC0,0x40,0x40,0x00,0x00,0x00,

  42. 0x10,0x00,0x10,0x80,0x10,0x40,0x10,0x30,0x10,0x0C,0x90,0x23,0x7F,0x20,0x10,0x10,--名0xF0,0x3F,0x12,0x44,0x14,0x42,0x10,0x41,0xD0,0x40,0x18,0x40,0x10,0x78,0x00,0x00,

  43. 0x80,0x00,0x40,0x00,0x20,0x00,0xF8,0xFF,0x87,0x00,0x40,0x00,0x30,0x00,0x0F,0x00,--作
  44. 0xF8,0xFF,0x88,0x08,0x88,0x08,0xC8,0x08,0x88,0x0C,0x0C,0x08,0x08,0x00,0x00,0x00,

  45. 0x00,0x00,0x00,0xFF,0x00,0x41,0x7E,0x41,0x22,0x41,0x22,0x41,0xA2,0xFF,0x22,0x01,--品
  46. 0x22,0xFF,0x22,0x41,0x22,0x41,0x7F,0x41,0x02,0x41,0x80,0xFF,0x00,0x01,0x00,0x00,

  47. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x7C,0x3B,0xFE,--!
  48. 0x3B,0xFE,0x10,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  49. 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,-图
  50. 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,

  51. 0x00,0x01,0x40,0x00,0x10,0x00,0x04,0x00,0x01,0x00,0x04,0x00,0x10,0x00,0x40,0x00,
  52. 0x00,0x01,0x00,0x04,0x00,0x10,0x00,0x04,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,

  53. 0x00,0x01,0x40,0x00,0x10,0x00,0x04,0x00,0x01,0x00,0x04,0x00,0x10,0x00,0x40,0x00,-案
  54. 0x00,0x01,0x00,0x04,0x00,0x10,0x00,0x04,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,

  55. 0xF0,0x00,0x08,0x01,0x14,0x02,0x52,0x04,0x12,0x08,0x12,0x10,0x24,0x22,0x58,0x55,
  56. 0x88,0x68,0x04,0x20,0x12,0x10,0x12,0x08,0x52,0x04,0x14,0x02,0x08,0x01,0xF0,0x00
  57. };


  58. unsigned char code  saomiao[]=--字幕扫描数组
  59. {
  60.   0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,
  61.   0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,0x00
  62. };
  63. unsigned char tone_l_h[]={0xf0,0xf9,0xf9,0xfa,0xfa,0xfb,0xfb,0xfc};--底音高8位频率
  64. unsigned char tone_l_l[]={0xf0,0x21,0xe0,0x8b,0xd7,0x68,0xe8,0x5b};--底音低8位频率
  65. unsigned char tone_m_h[]={0xf0,0xfc,0xfc,0xfd,0xfd,0xfd,0xfd,0xfe};--中音高8位频率
  66. unsigned char tone_m_l[]={0xf0,0x8f,0xef,0x45,0x6c,0xb5,0xf5,0x2e};--中音低8位频率
  67. unsigned char tone_h_h[]={0xf0,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xff};--高音高8位频率
  68. unsigned char tone_h_l[]={0xf0,0x47,0x77,0xa2,0xb6,0xda,0xfa,0x16};--高音低8位频率
  69. unsigned char code number[]={0xc0,0xf9,0xa4,0xb0,0X99,0X92,0X82,0Xf8,0X80,0X90};--数码管显示0~9
  70. unsigned char tone_yin[]={0xf7,0xbf,0xfe};--低中高音节数码管显示
  71. unsigned char *s=saomiao,*h=hanzi,*w,*t,flog1=0,flog2=0,x,m,count,TH_M0,TL_M0,n;
  72. unsigned int cx;

  73. void delay(unsigned int num)--普通延时函数,用于调整音调
  74. {
  75.   unsigned int z;
  76.   for(z=0;z<num;z++)
  77.   {;}
  78. }

  79. delay_1()--倒计时延时函数,可控制执行次数,用于控制字幕滚动速度
  80. {
  81.   cx--;
  82.   if(cx!=0) return(1);
  83.   if(cx==0) return(0);
  84.   }

  85. void write_1(unsigned char byte)--字模寄存器写入(根据点阵特点,调整输出次序)
  86. {
  87.   unsigned char i;
  88.   for(i=0;i<8;i++)
  89.    {
  90.     SRCK_1=0;
  91.     if((byte&0x01)==0)
  92.       SER_IN_1=0;
  93.     else SER_IN_1=1;
  94.      SRCK_1=1;
  95.      byte=byte>>1;
  96.    }
  97.   SRCK_1=0;
  98. }


  99. void write_2(unsigned char byte)--扫描行寄存器写入
  100. {
  101.   unsigned char i;
  102.   for(i=0;i<8;i++)
  103.    {
  104.     SRCK_2=0;
  105.     if((byte&0x80)==0)
  106.          SER_IN_2=0;
  107.     else SER_IN_2=1;
  108.     SRCK_2=1;
  109.     byte=byte<<1;
  110.     }
  111.   SRCK_2=0;
  112. }


  113. void scan()--执行一次,扫描一行
  114.   {
  115.     unsigned char j;
  116.     flog1++;
  117.     if(flog1==17)
  118.       {
  119.         flog1=1;
  120.         s=saomiao;
  121.       }
  122.     for(j=0;j<2;j++)
  123.       {
  124.         write_2(*(s++));
  125.       }
  126.    
  127.   }

  128. void gundong(unsigned char n)--每次赋值是输入2个值,n从1开始,产生滚动
  129. {
  130.   unsigned char j;
  131.   if(flog2==0)
  132.     {
  133.      t=&hanzi[2*(n-1)];
  134.      if(n<=((num-1)*16+1))
  135.        {
  136.          w=&hanzi[2*(n-1)+32];
  137.        }
  138.       else
  139.        {
  140.          w=&hanzi[2*(n-1)-2*(num-1)*16];--每次只显示16位,32个字节,w是尾地址
  141.        }
  142.      h=t;
  143.      flog2++;
  144.     }
  145.      if(h==w)--他和下面的IF不可调换次序
  146.     {
  147.      h=t;
  148.     }
  149.     if(h==(hanzi+num*32))
  150.     {
  151.      h=hanzi;
  152.     }
  153.   for(j=0;j<2;j++)
  154.     {
  155.      write_1(*(h++));
  156.     }
  157. }


  158. main()
  159. {
  160.   unsigned char i;
  161.   cx=speed;
  162.   SRCK_1=0;
  163.   SRCK_2=0;
  164.   RCK=0;--清零很重要???
  165.   n=0;
  166.   EA=1;--打开中断
  167.   ET0=1;
  168.   ET1=1;--易错点,定时器打开,中断也得开
  169.   TMOD=0x11;--打开定时器
  170.   TR0=1;
  171.   TR1=1;
  172.   PT0=1;--优先级设定
  173.   while(1)
  174.     {
  175.      for(i=0;i<song_num;i++)
  176.        {
  177.          x=song[i];
  178.          m=song[i]/10;
  179.          switch(m)--分中底高位赋值
  180.            {
  181.              case 0:{TH_M0=tone_l_h[x];TL_M0=tone_l_l[x];break;}
  182.              case 1:{TH_M0=tone_m_h[x];TL_M0=tone_m_l[x];break;}
  183.              case 2:{TH_M0=tone_h_h[x];TL_M0=tone_h_l[x];break;}
  184.            }
  185.          TH0=TH_M0;
  186.          TL0=TL_M0;
  187.          delay(song_speed[i]*20);--节奏控制
  188.       }
  189.    }
  190. }

  191. void play_music(void) interrupt 1 --输出音乐函数+数码输出函数
  192. {
  193. TH0=TH_M0;
  194. TL0=TL_M0;
  195. if(x!=0) buz=!buz;
  196. if(x==0) buz=0;
  197. count++;
  198. if(count==1)
  199.   {
  200.    DIG1=0;
  201.    DIG2=1;
  202.    P0=tone_yin[m];
  203.   }
  204. if(count==2)
  205. {
  206.   count=0;
  207.   DIG1=1;
  208.   DIG2=0;
  209.   P0=number[x];
  210. }
  211. }

  212. void play(void) interrupt 3

  213. {
  214.   if(n==(num*16))
  215.     {
  216.      n=0;
  217.     }
  218.   n++;   
  219.   while(delay_1())
  220.     {
  221.      gundong(n);
  222.      scan();   
  223.      RCK=0;
  224.      RCK=1;   
  225.     }
  226.   flog1=0;
  227.   flog2=0;
  228.   cx=speed;
  229.   s=saomiao;
  230.   TH1=0xEF;--放后面,防止不准
  231.   TL1=0xEF;
  232.   TF1=0;
  233. }
复制代码




评分

参与人数 1黑币 +8 收起 理由
xwnc + 8 很给力!

查看全部评分

回复

使用道具 举报

ID:98494 发表于 2015-12-11 18:45 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

ID:99700 发表于 2015-12-20 23:45 来自手机 | 显示全部楼层
很酷耶,电路图能不能分享一下呢,我也想做一个
回复

使用道具 举报

ID:70042 发表于 2015-12-22 08:42 | 显示全部楼层
不错,有时间自己也做一个玩玩               
回复

使用道具 举报

ID:99700 发表于 2015-12-22 10:26 来自手机 | 显示全部楼层
请问有原理图能供参考一下么
回复

使用道具 举报

ID:100555 发表于 2015-12-26 00:15 | 显示全部楼层
顶一个 有没有电路图了 谢谢
回复

使用道具 举报

ID:1 发表于 2015-12-26 00:43 | 显示全部楼层
meinv 发表于 2015-12-22 10:26
请问有原理图能供参考一下么

你可以参考这个图,改下端口即可 image.jpg

  1. #include <reg52.h>

  2. #define uchar unsigned char

  3. uchar i,j,k=15;

  4. sbit  xsi=P2^0;

  5. sbit  xrck=P2^1;

  6. sbit  xsck=P2^2;

  7. sbit  ysi=P2^3;

  8. sbit  yrck=P2^4;

  9. sbit  ysck=P2^5;

  10. sbit kg= P3^2;

  11. uchar code zbm[][32]={

  12. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

  13. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,},

  14. {0xFF,0xFF,0xFF,0xF7,0xBF,0xF7,0xBF,0xFB,0xBF,0xFD,0x03,0xE0,0xFF,0xFF,0xFF,0xFF,

  15. 0x01,0xF0,0x7F,0xEF,0xBF,0xEF,0x9F,0xEF,0xDF,0xEF,0xFF,0xF1,0xFF,0xFF,0xFF,0xFF},/*"北",0*/

  16. {0xF7,0xFF,0xF7,0xFF,0xF7,0xEF,0xF7,0xF3,0x37,0xFF,0xB7,0xFE,0xB6,0xDE,0xD5,0x80,

  17. 0xDB,0xFE,0x5B,0xFF,0x9B,0xFB,0xFB,0xF7,0xFB,0xE7,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF},/*"京",1*/

  18. {0xFF,0xEF,0x5F,0xF7,0x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xDF,0xF7,0xDF,0xEF,0xEF,0x1F,0xF0,0xFF,0xFF},/*"D",2*/

  44. {0xFF,0xDF,0xFF,0xE7,0xFF,0xFF,0xFF,0xFF,0x7F,0xF4,0x7F,0xED,0x81,0xFD,0xB7,0xFD},

  45. {0xB7,0xF5,0xBB,0xED,0x3B,0xFE,0xFF,0xF7,0xFF,0xEF,0xFF,0xCF,0xFF,0xFF,0xFF,0xFF},/*"点",3*/

  46. {0xFF,0xFF,0x03,0xE0,0xBB,0xFF,0x6D,0xFF,0x11,0xFB,0xFF,0xFB,0x37,0xFB,0x57,0xFB},

  47. {0x67,0xFB,0x19,0x80,0xBB,0xFD,0xBB,0xFD,0xBF,0xFD,0xFF,0xFD,0xFF,0xFD,0xFF,0xFF},/*"阵",4*/

  48. {0xFF,0xEF,0xFF,0xF7,0xFF,0xF9,0x7F,0xFE,0x81,0xBD,0x75,0xDD,0x65,0xE5,0x55,0xF8},

  49. {0xB6,0xFD,0x9A,0xFD,0x28,0x80,0xBC,0xFE,0xBF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFF},/*"屏",5*/

  50. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},

  51. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,},

  52. };

  53. void ys (uchar a) //延时

  54. {

  55. uchar b;

  56. for (;a>0;a--)

  57. for (b=100;b>0;b--) ;

  58. }

  59. void yfs() //Y轴发数

  60. {

  61. ysck=0;

  62. yrck=0;

  63. k++;

  64. if (k==16)

  65. {

  66. k=0;

  67. ysi=0;

  68. }

  69. else

  70. ysi=1;

  71. ysck=1;

  72. P2=P2|0X14;

  73. //相当于   xrck=1;  yrck=1;

  74. }

  75. void xfs(uchar a)   //X轴发数

  76. {

  77. uchar b,a1,a2;

  78. a1=~zbm[6][a*2+1];

  79. a2=~zbm[6][a*2];

  80. xsck=0;

  81. xrck=0;

  82. for (b=0;b<8;b++)

  83. {

  84. a1=a1<<1;

  85. xsi=CY;

  86. xsck=1;

  87. xsck=0;

  88. }

  89. for (b=0;b<8;b++)

  90. {

  91. a2=a2<<1;

  92. xsi=CY;

  93. xsck=1;

  94. xsck=0;

  95. }

  96. }  

  97. void  fs(uchar a)      //X轴发数

  98. {

  99. uchar b;

  100. xsck=0;

  101. xrck=0;

  102. for (b=0;b<8;b++)

  103. {

  104. a=a<<1;

  105. xsi=CY;

  106. xsck=1;

  107. xsck=0;

  108. }

  109. }

  110. void gdhs(uchar *zz,uchar N,uchar Time) //流动显示N个汉字    滚动函数

  111. { //参数三个:字符串字模首地址、字数、显示流动速度

  112. uchar FontNum,i,j,row; //循环变量,字数计数、16次流动、16列扫描

  113. for(FontNum=0;FontNum<N;FontNum++)

  114. {

  115. for(i=0;i<16;i++) //字到字流动 16次左移才能完成

  116. {

  117. for(j=0;j<Time;j++) //显示延迟,决定流动速度

  118. {

  119. k=15;

  120. for(row=0;row<16;row++) //显示16*16屏幕一次

  121. {

  122. yfs(); //选通显示列  //行选线,P3 低四位

  123. fs (~*(zz+FontNum*32+(i+row)*2+1)); //以移动偏移为基础获取新数据

  124. fs(~*(zz+FontNum*32+(i+row)*2)); //获取显示数据 循环显示关键算法

  125. ys (12); //适当延时

  126. }

  127. }

  128. }

  129. }

  130. }

  131. void wbzd ()  interrupt   0   //外部中断

  132. {

  133.   j++;

  134.   if (j>1)

  135.   j=0;

  136.   ys(10);

  137.   while (!kg)

  138.   {

  139.    k=15;

  140.   for (i=0;i<16;i++)

  141.   {

  142.    yfs();

  143.    xfs(i);

  144. ys(10);

  145.    }

  146.   }

  147. if (j==0)

  148.    gdhs(zbm,8,2);

  149. if (j==1)

  150. gdhs(zbm1,10,1);

  151. }

  152. void main ()

  153. {

  154. EA = 1; //打开总中断

  155. EX0=1;

  156. IT0=1;

  157. while (1)

  158. {

  159.      if (j==0)

  160.    gdhs(zbm,8,5);

  161.   if (j==1)

  162.      gdhs(zbm1,10,3);

  163. }

  164. }
复制代码


回复

使用道具 举报

ID:119015 发表于 2016-5-8 13:47 | 显示全部楼层
admin 发表于 2015-12-26 00:43
你可以参考这个图,改下端口即可

电路图不完整啊啊啊啊啊啊啊啊啊啊啊啊啊
回复

使用道具 举报

ID:126077 发表于 2016-6-10 12:00 | 显示全部楼层
楼主能不能给发一下点阵的仿真图,急求
回复

使用道具 举报

ID:142098 发表于 2016-10-18 17:36 | 显示全部楼层
发个压缩包不是更好一点?
回复

使用道具 举报

ID:143435 发表于 2016-10-19 16:52 | 显示全部楼层
看起来很有趣  试试
回复

使用道具 举报

ID:148523 发表于 2016-11-17 22:12 | 显示全部楼层
电路图呢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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