Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /*
  2. Melody
  3.  
  4. Plays a melody
  5.  
  6. circuit:
  7. * 8-ohm speaker on digital pin 8
  8.  
  9. created 21 Jan 2010
  10. modified 30 Aug 2011
  11. by Tom Igoe
  12.  
  13. This example code is in the public domain.
  14.  
  15. http://www.arduino.cc/en/Tutorial/Tone
  16.  
  17. */
  18. #include "pitches.h"
  19.  
  20. // notes in the melody:
  21. int melody[] = {
  22. //NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
  23. // NOTE_E7, NOTE_B6, NOTE_E7, NOTE_B6
  24.  
  25. //INTRO (6notes)
  26. NOTE_G5, NOTE_C6, NOTE_E6, NOTE_G6, NOTE_E6, NOTE_G6,0,
  27. //한눈 팔지마 누가 뭐래도 내꺼 (내꺼) (16 notes)
  28. NOTE_E6, NOTE_E6, NOTE_E6, NOTE_E6, NOTE_E6, NOTE_E6, NOTE_E6, NOTE_E6, NOTE_F6, NOTE_G6, NOTE_G6, NOTE_D6, 0, NOTE_G6, NOTE_D6,0,
  29. //다른 여자랑 말도 섞지마 난 니꺼 (난 니꺼) (20 notes)
  30. NOTE_D6, NOTE_E6, NOTE_F6, NOTE_F6, NOTE_F6, NOTE_F6, NOTE_F6, NOTE_D6, NOTE_D6, NOTE_E6, NOTE_F6, NOTE_A6, NOTE_G6, 0, NOTE_C6, NOTE_C7, NOTE_G6, NOTE_E6, NOTE_C6,0
  31. };
  32.  
  33. // note durations: 4 = quarter note, 8 = eighth note, etc.:
  34. int noteDurations[] = {
  35. // 4, 8, 8, 4, 4, 4, 4, 4
  36. //4,4,4,4
  37.  
  38. //INTRO(6 notes)
  39. 8,8,8,4,8,2,2,
  40. //한눈 팔지마 누가 뭐래도 내꺼 (내꺼) (16 notes)
  41. 4,4,4,4,4,8,8,8,8,4,4,8, 2, 4,8, 2,
  42. //다른 여자랑 말도 섞지마 난 니꺼 (난 니꺼) (20 notes)
  43. 8,8,4,4,4,4,4,4,8,8,4,4,4,2,8,8,8,8,8,2
  44.  
  45.  
  46. };
  47.  
  48. void setup() {
  49. // iterate over the notes of the melody:
  50. for (int thisNote = 0; thisNote < 42; thisNote++) {
  51.  
  52. // to calculate the note duration, take one second
  53. // divided by the note type.
  54. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
  55. int noteDuration = 1000 / noteDurations[thisNote];
  56. tone(8, melody[thisNote], noteDuration);
  57.  
  58. // to distinguish the notes, set a minimum time between them.
  59. // the note's duration + 30% seems to work well:
  60. int pauseBetweenNotes = noteDuration * 1.30;
  61. delay(pauseBetweenNotes);
  62. // stop the tone playing:
  63. noTone(8);
  64. }
  65. }
  66.  
  67. void loop() {
  68. // no need to repeat the melody.
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement