SHARE
TWEET

Untitled

a guest Mar 23rd, 2016 342 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //S = #
  2. #define C1  33
  3. #define CS1 35
  4. #define D1  37
  5. #define DS1 39
  6. #define E1  41
  7. #define F1  44
  8. #define FS1 46
  9. #define G1  49
  10. #define GS1 52
  11. #define A1  55
  12. #define AS1 58
  13. #define B1  62
  14. #define C2  65
  15. #define CS2 69
  16. #define D2  73
  17. #define DS2 78
  18. #define E2  82
  19. #define F2  87
  20. #define FS2 93
  21. #define G2  98
  22. #define GS2 104
  23. #define A2  110
  24. #define AS2 117
  25. #define B2  123
  26. #define C3  131
  27. #define CS3 139
  28. #define D3  147
  29. #define DS3 156
  30. #define E3  165
  31. #define F3  175
  32. #define FS3 185
  33. #define G3  196
  34. #define GS3 208
  35. #define A3  220
  36. #define AS3 233
  37. #define B3  247
  38. #define C4  262
  39. #define CS4 277
  40. #define D4  294
  41. #define DS4 311
  42. #define E4  330
  43. #define F4  349
  44. #define FS4 370
  45. #define G4  392
  46. #define GS4 415
  47. #define A4  440
  48. #define AS4 466
  49. #define B4  494
  50. #define C5  523
  51. #define CS5 554
  52. #define D5  587
  53. #define DS5 622
  54. #define E5  659
  55. #define F5  698
  56. #define FS5 740
  57. #define G5  784
  58. #define GS5 831
  59. #define A5  880
  60. #define AS5 932
  61. #define B5  988
  62. #define C6  1047
  63. #define CS6 1109
  64. #define D6  1175
  65. #define DS6 1245
  66. #define E6  1319
  67. #define F6  1397
  68. #define FS6 1480
  69. #define G6  1568
  70. #define GS6 1661
  71. #define A6  1760
  72. #define AS6 1865
  73. #define B6  1976
  74. #define C7  2093
  75. #define CS7 2217
  76. #define D7  2349
  77. #define DS7 2489
  78. #define E7  2637
  79. #define F7  2794
  80. #define FS7 2960
  81. #define G7  3136
  82. #define GS7 3322
  83. #define A7  3520
  84. #define AS7 3729
  85. #define B7  3951
  86. #define C8  4186
  87. #define CS8 4435
  88. #define D8  4699
  89. #define DS8 4978
  90.  
  91. int otj[] =  
  92. {
  93.   E4, E4, F4, G4, G4, F4, E4, D4, C4, C4, D4, E4, E4, D4, D4,
  94.   E4, E4, F4, G4, G4, F4, E4, D4, C4, C4, D4, E4, D4, C4, C4,
  95.   D4, D4, E4, C4, D4, F4, E4, C4, D4, F4, E4, D4, C4, D4, G4,
  96.   E4, E4, F4, G4, G4, F4, E4, D4, C4, C4, D4, E4, D4, C4, C4
  97. };
  98. int mario[] =
  99. {
  100.   E7, E7, 0, E7, 0, C7, E7, 0,
  101.   G7, 0, 0,  0, G6, 0, 0, 0,
  102.  
  103.   C7, 0, 0, G6, 0, 0, E6, 0,
  104.   0, A6, 0, B6, 0, AS6, A6, 0,
  105.  
  106.   G6, E7, G7, A7, 0, F7, G7,
  107.   0, E7, 0, C7, D7, B6, 0, 0,
  108.  
  109.   C7, 0, 0, G6, 0, 0, E6, 0,
  110.   0, A6, 0, B6, 0, AS6, A6, 0,
  111.  
  112.   G6, E7, G7, A7, 0, F7, G7,
  113.   0, E7, 0, C7, D7, B6, 0, 0
  114. };
  115. int otjr[] =
  116. {
  117.   4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,
  118.   4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,
  119.   4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,
  120.   4,4,4,4,4,4,4,4,4,4,4,4,4,4,2
  121. };
  122. int marior[] = {
  123.   12, 12, 12, 12,
  124.   12, 12, 12, 12,
  125.   12, 12, 12, 12,
  126.   12, 12, 12, 12,
  127.  
  128.   12, 12, 12, 12,
  129.   12, 12, 12, 12,
  130.   12, 12, 12, 12,
  131.   12, 12, 12, 12,
  132.  
  133.   9, 9, 9,
  134.   12, 12, 12, 12,
  135.   12, 12, 12, 12,
  136.   12, 12, 12, 12,
  137.  
  138.   12, 12, 12, 12,
  139.   12, 12, 12, 12,
  140.   12, 12, 12, 12,
  141.   12, 12, 12, 12,
  142.  
  143.   9, 9, 9,
  144.   12, 12, 12, 12,
  145.   12, 12, 12, 12,
  146.   12, 12, 12, 12,
  147. };
  148.  
  149. int t1 = 3;
  150. int t2 = 4;
  151. int cteni1;
  152. int cteni2;
  153.  
  154. void setup() {
  155.     pinMode(t1, INPUT);
  156.     pinMode(t2, INPUT);
  157.     cteni1 = digitalRead(t1);
  158.     cteni2 = digitalRead(t2);
  159. }
  160.  
  161. void loop() {
  162.   if (digitalRead(cteni1 == HIGH))
  163.     {
  164.         // přehrání melodie otj
  165.         for (int tnota = 0; tnota < 63; tnota++)
  166.         {
  167.           //zjištění délky noty
  168.           int dnot = 1000/otjr[tnota];
  169.           tone(2, otj[tnota],dnot); //port2
  170.           int mnot = dnot * 1.30;
  171.           delay(mnot);
  172.           noTone(62);    
  173.         }
  174.     }
  175.   else if (digitalRead(cteni2 == HIGH))
  176.      {
  177.       for (int tnota = 0; tnota < 270; tnota++)
  178.         {
  179.           int dnot = 1000/marior[tnota];
  180.           tone(2, mario[tnota],dnot); //port2
  181.           int mnot = dnot * 1.30;
  182.           delay(mnot);
  183.           noTone(270);    
  184.         }
  185.      }
  186.  
  187. }
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