Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. /*
  2. Скетч для проигрывания имперского марша на пищалке от древнего компа
  3.  
  4. Частоты и ноты скопипизжены отсюда:
  5. http://wiki.tiprocessors.com/index.php/Playing_The_Imperial_March
  6. */
  7.  
  8. const int speakerPin = 4; // Пищалка подключена к этому цифровому пину (для изменения пина нужно изменить еще пару записей внизу)
  9.  
  10. // Частоты нот
  11. const int c = 261;
  12. const int d = 294;
  13. const int e = 329;
  14. const int f = 349;
  15. const int g = 391;
  16. const int gS = 415;
  17. const int a = 440;
  18. const int aS = 455;
  19. const int b = 466;
  20. const int cH = 523;
  21. const int cSH = 554;
  22. const int dH = 587;
  23. const int dSH = 622;
  24. const int eH = 659;
  25. const int fH = 698;
  26. const int fSH = 740;
  27. const int gH = 784;
  28. const int gSH = 830;
  29. const int aH = 880;
  30.  
  31. void beep(int ton, int time)
  32. {
  33. tone(4, ton, time); //тут цифра пина
  34. delay(time + 20);
  35. }
  36.  
  37. void setup()
  38. {
  39. noTone(4); //и тут тоже
  40. }
  41.  
  42. void loop()
  43. {
  44. beep(a, 500);
  45. beep(a, 500);
  46. beep(a, 500);
  47. beep(f, 350);
  48. beep(cH, 150);
  49. beep(a, 500);
  50. beep(f, 350);
  51. beep(cH, 150);
  52. beep(a, 650);
  53.  
  54. delay(250);
  55. //Конец 1 части
  56.  
  57. beep(eH, 500);
  58. beep(eH, 500);
  59. beep(eH, 500);
  60. beep(fH, 350);
  61. beep(cH, 150);
  62. beep(gS, 500);
  63. beep(f, 350);
  64. beep(cH, 150);
  65. beep(a, 650);
  66.  
  67. delay(250);
  68. //Конец второй части
  69.  
  70. beep(aH, 500);
  71. beep(a, 300);
  72. beep(a, 150);
  73. beep(aH, 400);
  74. beep(gSH, 200);
  75. beep(gH, 200);
  76. beep(fSH, 125);
  77. beep(fH, 125);
  78. beep(fSH, 250);
  79.  
  80. delay(250);
  81.  
  82. beep(aS, 250);
  83. beep(dSH, 400);
  84. beep(dH, 200);
  85. beep(cSH, 200);
  86. beep(cH, 125);
  87. beep(b, 125);
  88. beep(cH, 250);
  89.  
  90. delay(250);
  91.  
  92. beep(f, 125);
  93. beep(gS, 500);
  94. beep(f, 375);
  95. beep(a, 125);
  96. beep(cH, 500);
  97. beep(a, 375);
  98. beep(cH, 125);
  99. beep(eH, 650);
  100.  
  101. //конец третьей части (звучит херовенько, надо бы подправить, но мне влом)
  102.  
  103. beep(aH, 500);
  104. beep(a, 300);
  105. beep(a, 150);
  106. beep(aH, 400);
  107. beep(gSH, 200);
  108. beep(gH, 200);
  109. beep(fSH, 125);
  110. beep(fH, 125);
  111. beep(fSH, 250);
  112.  
  113. delay(250);
  114.  
  115. beep(aS, 250);
  116. beep(dSH, 400);
  117. beep(dH, 200);
  118. beep(cSH, 200);
  119. beep(cH, 125);
  120. beep(b, 125);
  121. beep(cH, 250);
  122.  
  123. delay(250);
  124.  
  125. beep(f, 250);
  126. beep(gS, 500);
  127. beep(f, 375);
  128. beep(cH, 125);
  129. beep(a, 500);
  130. beep(f, 375);
  131. beep(cH, 125);
  132. beep(a, 650);
  133. //усьо, зэ энд
  134.  
  135. noTone(4); //и даже тут
  136. delay(10000);
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement