当前位置:   article > 正文

51单片机蜂鸣器实现歌曲《起风了》代码_51单片机歌曲代码大全

51单片机歌曲代码大全

 《起风了》原唱:买辣椒也用券
于2022年1月23日晚正式回归,如果林俊杰,周深都是怀念、悲哀、青春等那么买辣椒也用券则唱出青春美好时光,怀念过往岁月,美好时光的纪念磁带,原来以2018年那种美好回忆没有疫情,生活无忧无虑,岁月神偷的过往,可我们2018年的时光如今早已回不去......

  1. #include <reg52.h>
  2. #define uint unsigned int
  3. #define uchar unsigned char
  4. sbit voice=P1^5; //单片机开发板型号不同需要修改为所对应的蜂鸣器管脚
  5. uchar code sound[]={0xff,
  6. 0x2b,0x30,0x30,0x10,0x2b,0x30,0x30,0x10,0x2b,0x20,0x26,0x20,0x20,0x20,
  7. 0x26,0x20,0x2b,0x30,0x30,0x10,0x2b,0x30,0x30,0x10,0x2b,0x10,0x26,0x10,
  8. 0x2b,0x10,0x30,0x10,0x40,0x20,0x40,0x20,0x2b,0x30,0x30,0x10,0x2b,0x30,
  9. 0x30,0x10,0x2b,0x20,0x26,0x20,0x20,0x20,0x26,0x20,0x2b,0x30,0x26,0x10,
  10. 0x2b,0x20,0x30,0x20,0x2b,0x20,0x2b,0x20,0xff,0x20,0xff,0x20,0x2b,0x30,
  11. 0x30,0x10,0x2b,0x30,0x30,0x10,0x2b,0x20,0x26,0x20,0x20,0x20,0x26,0x20,
  12. 0x2b,0x30,0x26,0x10,0x2b,0x20,0x30,0x20,0x39,0x20,0x39,0x20,0x26,0x10,
  13. 0x2b,0x10,0x30,0x10,0x2b,0x10,0x30,0x20,0x30,0x20,0x26,0x10,0x2b,0x10,
  14. 0x30,0x10,0x2b,0x10,0x30,0x30,0x20,0x10,0x26,0x10,0x2b,0x10,0x30,0x10,
  15. 0x2b,0x10,0x30,0x20,0x30,0x20,0x30,0x20,0x2b,0x20,0x26,0x20,0x30,0x20,0x1c,0x20,0x20,0x10,0x1c,0x10,
  16. 0x1c,0x30,0x30,0x10,0x19,0x20,0x1c,0x10,0x19,0x10,0x19,0x20,0x19,0x20,
  17. 0x1c,0x10,0x19,0x10,0x19,0x20,0x26,0x20,0x18,0x10,0x15,0x10,0x18,0x10,
  18. 0x19,0x10,0x1c,0x20,0x20,0x20,0x1c,0x20,0x20,0x10,0x1c,0x10,0x1c,0x10,
  19. 0x20,0x10,0x1c,0x10,0x20,0x10,0x1c,0x20,0x20,0x10,0x2b,0x10,0x2b,0x10,
  20. 0x20,0x20,0x20,0x10,0x26,0x20,0x26,0x20,0x30,0x20,0x2b,0x20,0x26,0x20,
  21. 0x30,0x20,0x1c,0x20,0x20,0x10,0x1c,0x10,0x1c,0x30,0x30,0x10,0x19,0x20,
  22. 0x1c,0x10,0x19,0x10,0x19,0x20,0x19,0x20,0x1c,0x10,0x19,0x10,0x19,0x20,
  23. 0x26,0x20,0x18,0x10,0x15,0x10,0x18,0x10,0x19,0x10,0x1c,0x20,0x20,0x20,
  24. 0x1c,0x20,0x13,0x10,0x13,0x10,0x13,0x20,0x20,0x20,0x1c,0x20,0x13,0x10,
  25. 0x13,0x10,0x13,0x10,0x20,0x20,0x1c,0x10,0x1c,0x20,0x1c,0x20,0x1c,0x20,
  26. 0x1c,0x20,0xff,0x20,0xff,0x20, 0x18,0x20,0x15,0x20,0x13,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,0x0e,0x10,
  27. 0x10,0x10,0x10,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,0x19,0x10,0x18,0x10,
  28. 0x18,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,
  29. 0x0e,0x10,0x10,0x10,0x10,0x10,0x13,0x30,0x15,0x20,0x18,0x10,0x1c,0x10,
  30. 0x1c,0x10,0x18,0x20,0x1c,0x10,0x15,0x10,0x18,0x10,0x1c,0x20,0x1c,0x10,
  31. 0x18,0x30,0x13,0x20,0x13,0x20,0x13,0x10,0x12,0x10,0x13,0x20,0x13,0x10,
  32. 0x15,0x20,0xff,0x20,0xff,0x20,0x18,0x20,0x15,0x20,0x13,0x20,0x0e,0x10,0x10,0x10,
  33. 0x10,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,
  34. 0x15,0x20,0x13,0x20,0x0e,0x10,0x10,0x10,0x10,0x20,0x0e,0x10,0x10,0x10,
  35. 0x10,0x20,0x0e,0x10,0x10,0x10,0x10,0x10,0x13,0x30,0x15,0x20,0x18,0x10,
  36. 0x1c,0x10,0x1c,0x10,0x13,0x30,0x15,0x20,0x18,0x10,0x1c,0x10,0x1c,0x10,
  37. 0x18,0x30,0x18,0x20,0x18,0x20,0xff,0x20,0xff,0x20,0x1c,0x10,0x13,0x10,
  38. 0x15,0x20,0x18,0x10,0x1c,0x10,0x1c,0x10,0x13,0x30,0x15,0x20,0x18,0x10,
  39. 0x1c,0x10,0x1c,0x10,0x18,0x30,0x18,0x20,0x18,0x20,0x18,0x20,0x18,0x20,0x00,
  40. };
  41. uchar zdjs=0, jp;
  42. del(yj);
  43. void main(void)
  44. {
  45. uint dpjs=0;
  46. uchar yj;
  47. TMOD=0x01,IE=0x82;
  48. TH0=0xd8, TL0=0xef;
  49. TR0=1;
  50. while(1)
  51. {
  52. zdjs=0;
  53. dpjs++; yj=sound[dpjs];
  54. dpjs++; jp=sound[dpjs];
  55. while(zdjs!=jp)
  56. {
  57. if(yj!=0xff)
  58. {
  59. if(yj!=0)
  60. {
  61. voice=!voice;
  62. del(yj);
  63. }
  64. else
  65. {
  66. dpjs=0;
  67. break;
  68. }
  69. }
  70. else
  71. {
  72. voice=0;
  73. del(jp);
  74. }
  75. }
  76. }
  77. }
  78. time0() interrupt 1 using 1
  79. {
  80. TH0=0xd8, TL0=0xef;
  81. zdjs++;
  82. }
  83. del(yj)
  84. {
  85. uchar yj2=2;
  86. while(yj!=0)
  87. {
  88. while(yj2!=0)
  89. {
  90. yj2--;
  91. }
  92. yj2=2;
  93. yj--;
  94. }
  95. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/554286
推荐阅读
相关标签
  

闽ICP备14008679号