SHARE
TWEET

Untitled

a guest Nov 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PITCHES.H
  2.  
  3. /*************************************************
  4.  * Public Constants
  5.  *************************************************/
  6.  
  7. #define NOTE_B0  31
  8. #define NOTE_C1  33
  9. #define NOTE_CS1 35
  10. #define NOTE_D1  37
  11. #define NOTE_DS1 39
  12. #define NOTE_E1  41
  13. #define NOTE_F1  44
  14. #define NOTE_FS1 46
  15. #define NOTE_G1  49
  16. #define NOTE_GS1 52
  17. #define NOTE_A1  55
  18. #define NOTE_AS1 58
  19. #define NOTE_B1  62
  20. #define NOTE_C2  65
  21. #define NOTE_CS2 69
  22. #define NOTE_D2  73
  23. #define NOTE_DS2 78
  24. #define NOTE_E2  82
  25. #define NOTE_F2  87
  26. #define NOTE_FS2 93
  27. #define NOTE_G2  98
  28. #define NOTE_GS2 104
  29. #define NOTE_A2  110
  30. #define NOTE_AS2 117
  31. #define NOTE_B2  123
  32. #define NOTE_C3  131
  33. #define NOTE_CS3 139
  34. #define NOTE_D3  147
  35. #define NOTE_DS3 156
  36. #define NOTE_E3  165
  37. #define NOTE_F3  175
  38. #define NOTE_FS3 185
  39. #define NOTE_G3  196
  40. #define NOTE_GS3 208
  41. #define NOTE_A3  220
  42. #define NOTE_AS3 233
  43. #define NOTE_B3  247
  44. #define NOTE_C4  262
  45. #define NOTE_CS4 277
  46. #define NOTE_D4  294
  47. #define NOTE_DS4 311
  48. #define NOTE_E4  330
  49. #define NOTE_F4  349
  50. #define NOTE_FS4 370
  51. #define NOTE_G4  392
  52. #define NOTE_GS4 415
  53. #define NOTE_A4  440
  54. #define NOTE_AS4 466
  55. #define NOTE_B4  494
  56. #define NOTE_C5  523
  57. #define NOTE_CS5 554
  58. #define NOTE_D5  587
  59. #define NOTE_DS5 622
  60. #define NOTE_E5  659
  61. #define NOTE_F5  698
  62. #define NOTE_FS5 740
  63. #define NOTE_G5  784
  64. #define NOTE_GS5 831
  65. #define NOTE_A5  880
  66. #define NOTE_AS5 932
  67. #define NOTE_B5  988
  68. #define NOTE_C6  1047
  69. #define NOTE_CS6 1109
  70. #define NOTE_D6  1175
  71. #define NOTE_DS6 1245
  72. #define NOTE_E6  1319
  73. #define NOTE_F6  1397
  74. #define NOTE_FS6 1480
  75. #define NOTE_G6  1568
  76. #define NOTE_GS6 1661
  77. #define NOTE_A6  1760
  78. #define NOTE_AS6 1865
  79. #define NOTE_B6  1976
  80. #define NOTE_C7  2093
  81. #define NOTE_CS7 2217
  82. #define NOTE_D7  2349
  83. #define NOTE_DS7 2489
  84. #define NOTE_E7  2637
  85. #define NOTE_F7  2794
  86. #define NOTE_FS7 2960
  87. #define NOTE_G7  3136
  88. #define NOTE_GS7 3322
  89. #define NOTE_A7  3520
  90. #define NOTE_AS7 3729
  91. #define NOTE_B7  3951
  92. #define NOTE_C8  4186
  93. #define NOTE_CS8 4435
  94. #define NOTE_D8  4699
  95. #define NOTE_DS8 4978
  96.  
  97.  
  98. SKETCH
  99.  
  100. #include "pitches.h"
  101.  
  102. int melody[] = {
  103.   NOTE_C4
  104. };
  105.  
  106. // note durations: 4 = quarter note, 8 = eighth note, etc.:
  107. int noteDurations[] = {
  108.   4
  109. };
  110.  
  111. void setup() {
  112.  Serial.begin(9600);
  113. }
  114.  
  115. void loop() {
  116.   int sensorValue = analogRead(A0);
  117.   Serial.println(sensorValue);
  118.   if(sensorValue > 500){
  119.     Serial.println("REE");
  120.     for (int thisNote = 0; thisNote < 1; thisNote++) {
  121.       int noteDuration = 1000 / noteDurations[thisNote];
  122.       tone(8, melody[thisNote], noteDuration);
  123.       int pauseBetweenNotes = noteDuration * 1.30;
  124.       delay(pauseBetweenNotes);
  125.       // stop the tone playing:
  126.       noTone(8);
  127.       delay(1000);
  128.    }
  129.   }
  130. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top