Advertisement
Cookins

Untitled

Mar 19th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1.  
  2.  
  3. const int c = 261;
  4. const int d = 294;
  5. const int e = 329;
  6. const int f = 349;
  7. const int g = 391;
  8. const int gS = 415;
  9. const int a = 440;
  10. const int aS = 455;
  11. const int b = 466;
  12. const int cH = 523;
  13. const int cSH = 554;
  14. const int dH = 587;
  15. const int dSH = 622;
  16. const int eH = 659;
  17. const int fH = 698;
  18. const int fSH = 740;
  19. const int gH = 784;
  20. const int gSH = 830;
  21. const int aH = 880;
  22.  
  23. const int buzzerPin = 12; // Digital Pin 8
  24.  
  25. int counter = 0;
  26.  
  27. void setup()
  28. {
  29. //Setup pin modes
  30. pinMode(buzzerPin, OUTPUT); // Digital Pin 8
  31.  
  32. }
  33.  
  34. void loop()
  35. {
  36.  
  37. //Play first section
  38. firstSection();
  39.  
  40. //Play second section
  41. secondSection();
  42.  
  43. //Variant 1
  44. beep(f, 250);
  45. beep(gS, 500);
  46. beep(f, 350);
  47. beep(a, 125);
  48. beep(cH, 500);
  49. beep(a, 375);
  50. beep(cH, 125);
  51. beep(eH, 650);
  52.  
  53. delay(500);
  54.  
  55. //Repeat second section
  56. secondSection();
  57.  
  58. //Variant 2
  59. beep(f, 250);
  60. beep(gS, 500);
  61. beep(f, 375);
  62. beep(cH, 125);
  63. beep(a, 500);
  64. beep(f, 375);
  65. beep(cH, 125);
  66. beep(a, 650);
  67.  
  68. delay(650);
  69. }
  70.  
  71. void beep(int note, int duration)
  72. {
  73. //Play tone on buzzerPin
  74. tone(buzzerPin, note, duration);
  75.  
  76. //Stop tone on buzzerPin
  77. noTone(buzzerPin);
  78.  
  79. delay(50);
  80.  
  81. //Increment counter
  82. counter++;
  83. }
  84.  
  85. void firstSection()
  86. {
  87. beep(a, 500);
  88. beep(a, 500);
  89. beep(a, 500);
  90. beep(f, 350);
  91. beep(cH, 150);
  92. beep(a, 500);
  93. beep(f, 350);
  94. beep(cH, 150);
  95. beep(a, 650);
  96.  
  97. delay(500);
  98.  
  99. beep(eH, 500);
  100. beep(eH, 500);
  101. beep(eH, 500);
  102. beep(fH, 350);
  103. beep(cH, 150);
  104. beep(gS, 500);
  105. beep(f, 350);
  106. beep(cH, 150);
  107. beep(a, 650);
  108.  
  109. delay(500);
  110. }
  111.  
  112. void secondSection()
  113. {
  114. beep(aH, 500);
  115. beep(a, 300);
  116. beep(a, 150);
  117. beep(aH, 500);
  118. beep(gSH, 325);
  119. beep(gH, 175);
  120. beep(fSH, 125);
  121. beep(fH, 125);
  122. beep(fSH, 250);
  123.  
  124. delay(325);
  125.  
  126. beep(aS, 250);
  127. beep(dSH, 500);
  128. beep(dH, 325);
  129. beep(cSH, 175);
  130. beep(cH, 125);
  131. beep(b, 125);
  132. beep(cH, 250);
  133.  
  134. delay(350);
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement