找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1119|回复: 0
收起左侧

单片机电子贺卡源程序(红外+串口屏+MP3)

[复制链接]
ID:510519 发表于 2019-11-6 19:20 | 显示全部楼层 |阅读模式
  1. #include "stc12c5a60s2.H"
  2. #include "hongwai.h"
  3. #include "him.h"
  4. #include "speek.h"

  5. extern unsigned char  irtime;//红外用全局变量
  6. extern unsigned char IRcord[4];
  7. extern unsigned char irdata[33];
  8. extern bit irpro_ok,irok;
  9. extern bit fasong;
  10. extern uchar receive[35];
  11. extern unsigned char jm;
  12. extern unsigned char TF_MP3_2[] = {"E:\\1-歌曲\\缘分一道桥.mp3"};//泡沫
  13. extern unsigned char TF_MP3_3[] = {"E:\\1-歌曲\\泡沫.mp3"};    //攀登
  14. extern unsigned char TF_MP3_1[] = {"E:\\1-歌曲\\攀登.mp3"};  //缘分

  15. void Delay1000ms()                //@11.0592MHz 延时1s
  16. {
  17.         unsigned char i, j, k;

  18.         i = 43;
  19.         j = 6;
  20.         k = 203;
  21.         do
  22.         {
  23.                 do
  24.                 {
  25.                         while (--k);
  26.                 } while (--j);
  27.         } while (--i);
  28. }

  29. void main()
  30. {
  31.                 EA = 1;
  32.                 EX0init();         
  33.                 TIM0init();
  34.                 init();       
  35.                 while(1)//主循环
  36.    {               
  37. //                if(receive[2] == 0x02)   //第一首
  38. //                {
  39. //                        Delay1000ms();
  40. //                        UartInit();
  41. //                        SYN_VOL_Control(0x01);
  42. //                        Delay1000ms();
  43. //                        SYN_MP3(TF_MP3_3);
  44. //                        Delay1000ms();
  45. //                        Delay1000ms();
  46. //                        Delay1000ms();
  47. //                        Delay1000ms();
  48. //                        receive[2] = 0x00;
  49. //                }               
  50. //                if(receive[2] == 0x06)  //  第二首
  51. //                {
  52. //                        Delay1000ms();
  53. //                        UartInit();
  54. //                        SYN_VOL_Control(0x01);
  55. //                        Delay1000ms();
  56. //                        SYN_MP3(TF_MP3_2);
  57. //                        Delay1000ms();
  58. //                        Delay1000ms();
  59. //                        Delay1000ms();
  60. //                        Delay1000ms();
  61. //                        receive[2] = 0x00;
  62. //                }
  63. //                if(receive[2] == 0x04)    // 第三首
  64. //                {
  65. //                        Delay1000ms();
  66. //                        UartInit();
  67. //                        SYN_VOL_Control(0x01);
  68. //                        Delay1000ms();
  69. //                        SYN_MP3(TF_MP3_1);
  70. //                        Delay1000ms();
  71. //                        Delay1000ms();
  72. //                        Delay1000ms();
  73. //                        Delay1000ms();
  74. //                        receive[2] = 0x00;
  75. //                }
  76. //                if(receive[2] == 0x03)   //暂停
  77. //                {
  78. //                        Delay1000ms();
  79. //                        UartInit();
  80. //                        SYN_VOL_Control(0x01);
  81. //                        Delay1000ms();
  82. //                        SYN_TTS("已暂停");
  83. //                        Delay1000ms();
  84. //                        Delay1000ms();
  85. //                        Delay1000ms();
  86. //                        Delay1000ms();
  87. //                        receive[2] = 0x00;
  88. //                }
  89.     if(irok)      //如果接收好了进行红外处理
  90.           {   
  91.            Ircordpro();
  92.            irok=0;
  93.           }
  94.     if(irpro_ok)  //如果处理好后进行工作处理,如按对应的按键后显示对应的数字等     
  95.           {
  96.            Ir_work();
  97.           }
  98.                 if((jm == 0x0C) || (receive[2] == 0x02))                  //1
  99.                 {       
  100.                 send_string("page 1");  //第一首
  101.                 UART_Send_END();       
  102.                 Delay1000ms();
  103.                 UartInit();
  104.                 SYN_VOL_Control(0x01);
  105.                 Delay1000ms();
  106.                 SYN_MP3(TF_MP3_3);
  107.                 Delay1000ms();
  108.                 Delay1000ms();
  109.                 Delay1000ms();
  110.                 Delay1000ms();
  111.                         receive[2] = 0x00;
  112.                 jm = 0;
  113.                 }
  114.                 if((jm == 0x18) || (receive[2] == 0x06)  )                //2
  115.                 {
  116.                 send_string("page 4");  //第2
  117.                 UART_Send_END();       
  118.                 Delay1000ms();
  119.                 UartInit();
  120.                 SYN_VOL_Control(0x01);
  121.                 Delay1000ms();
  122.                 SYN_MP3(TF_MP3_2);
  123.                 Delay1000ms();
  124.                 Delay1000ms();
  125.                 Delay1000ms();
  126.                 Delay1000ms();
  127.                         receive[2] = 0x00;
  128.                 jm = 0;       
  129.                 }
  130.                 if((jm == 0x5E) || (receive[2] == 0x04))                //3
  131.                 {
  132.                 send_string("page 2");  //第三首
  133.                 UART_Send_END();       
  134.                 Delay1000ms();
  135.                 UartInit();
  136.                 SYN_VOL_Control(0x01);
  137.                 Delay1000ms();
  138.                 SYN_MP3(TF_MP3_1);
  139.                 Delay1000ms();
  140.                 Delay1000ms();
  141.                 Delay1000ms();
  142.                 Delay1000ms();
  143.                         receive[2] = 0x00;
  144.                 jm = 0;       
  145.                 }
  146.                 if(jm == 0x09)     //EQ
  147.                 {
  148.                 send_string("page 0");  //返回主页面
  149.                 UART_Send_END();       
  150.                 jm = 0;
  151.                 }
  152.                 if(jm == 0x44)                //<<   录音
  153.                 {
  154.                         send_string("page 5");
  155. //                Delay1000ms();
  156. //                UartInit();
  157. //                SYN_VOL_Control(0x01);
  158. //                Delay1000ms();
  159. //                SYN_MP3(TF_MP3_2);
  160. //                Delay1000ms();
  161. //                Delay1000ms();
  162. //                Delay1000ms();
  163. //                Delay1000ms();
  164.                 UART_Send_END();       
  165.                 jm = 0;
  166.                 }
  167.                 if((jm == 0x43) || (receive[2] == 0x03))         //停
  168.                 {
  169.                 send_string("page 3");  //
  170.                 UART_Send_END();       
  171.                 Delay1000ms();
  172.                 UartInit();
  173.                 SYN_VOL_Control(0x01);
  174.                 Delay1000ms();
  175.                 SYN_TTS("已暂停");
  176.                 Delay1000ms();
  177.                 Delay1000ms();
  178.                 Delay1000ms();
  179.                 Delay1000ms();
  180.                         receive[2] = 0x00;
  181.                 jm = 0;
  182.                 }
  183.                 if(jm == 0x40)   // >>    播音
  184.                 {
  185.                 send_string("page 6");  //
  186.                 UART_Send_END();
  187.                 jm = 0;
  188.                 }
  189.   }
  190. }
复制代码


电子贺卡.zip

53.29 KB, 下载次数: 17, 下载积分: 黑币 -5

回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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