Tutorial.Tone History

Show minor edits - Show changes to markup

April 08, 2013, at 05:15 PM by Roberto Guido - corrected link to image, thanks nid69ita for feedback
Changed lines 28-30 from:

to:

May 02, 2012, at 03:40 AM by Scott Fitzgerald -
Changed lines 39-40 from:
to:
May 02, 2012, at 03:39 AM by Scott Fitzgerald -
May 02, 2012, at 03:36 AM by Scott Fitzgerald -
Changed lines 50-51 from:
to:
November 16, 2011, at 04:07 AM by Scott Fitzgerald -
Changed lines 39-40 from:
to:
Changed lines 50-51 from:
to:
September 30, 2011, at 03:04 AM by Scott Fitzgerald -
Changed lines 39-40 from:
to:
Changed lines 50-51 from:
to:
September 23, 2010, at 10:30 PM by Christian Cerrito -
Changed lines 3-4 from:

Play Melody using the tone() function

to:

Play a Melody using the tone() function

September 23, 2010, at 10:30 PM by Christian Cerrito -
Changed lines 3-4 from:

Play Melody using the tone() function

to:

Play Melody using the tone() function

September 16, 2010, at 07:11 PM by Tom Igoe -
Changed lines 39-40 from:
to:
Changed lines 50-51 from:
to:
September 16, 2010, at 01:58 PM by Tom Igoe -
Changed lines 38-41 from:
to:
Changed lines 50-51 from:
to:
September 16, 2010, at 01:57 PM by Tom Igoe -
Added lines 38-39:
September 16, 2010, at 01:56 PM by Tom Igoe -
Changed lines 36-39 from:
to:
Changed line 48 from:
to:
September 16, 2010, at 01:56 PM by Tom Igoe -
Added lines 36-37:
Added lines 40-41:
September 16, 2010, at 01:54 PM by Tom Igoe -
Changed lines 35-36 from:
to:
Changed lines 37-39 from:
to:
September 16, 2010, at 01:54 PM by Tom Igoe -
Changed lines 50-51 from:
to:
September 16, 2010, at 01:54 PM by Tom Igoe -
Changed lines 34-39 from:

To make this file, click on the "new Tab" button in the upper right hand corner of the window. It looks like this:

The paste in the following code:

to:

The main sketch is as follows:

Changed lines 36-44 from:
to:
Added lines 40-51:
September 16, 2010, at 01:51 PM by Tom Igoe -
Changed lines 47-49 from:
to:
August 25, 2010, at 04:54 AM by Christian Cerrito -
Changed lines 9-10 from:
  • Arduino Board
  • Small Speaker
to:
  • Arduino board
  • 8 ohm small speaker
August 25, 2010, at 04:54 AM by Christian Cerrito -
Changed lines 55-56 from:
  • PitchFollower? - play a pitch on a piezo speaker depending on an analog input
  • SimpleKeyboard? - a three-key musical keyboard using force sensors and a piezo speaker.
to:
  • PitchFollower - play a pitch on a piezo speaker depending on an analog input
  • SimpleKeyboard - a three-key musical keyboard using force sensors and a piezo speaker.
August 25, 2010, at 04:52 AM by Christian Cerrito -
Changed lines 55-56 from:
  • Pitch Follower? - play a pitch on a piezo speaker depending on an analog input
  • Simple Keyboard? - a three-key musical keyboard using force sensors and a piezo speaker.
to:
  • PitchFollower? - play a pitch on a piezo speaker depending on an analog input
  • SimpleKeyboard? - a three-key musical keyboard using force sensors and a piezo speaker.
August 25, 2010, at 04:52 AM by Christian Cerrito -
Changed lines 51-52 from:
to:
August 25, 2010, at 04:49 AM by Christian Cerrito -
Added line 7:
Added line 14:
Changed lines 52-54 from:
to:
August 24, 2010, at 11:50 PM by Christian Cerrito -
Changed lines 46-54 from:
to:
August 24, 2010, at 11:34 PM by Christian Cerrito -
Added lines 7-12:

Hardware Required

  • Arduino Board
  • Small Speaker
  • 100 ohm resistor
  • hook-up wire
Changed lines 19-21 from:
to:

Connect one terminal of your speaker to digital pin 8 through a 100 ohm resistor. Connect the other terminal to ground.

August 24, 2010, at 08:09 AM by Christian Cerrito -
Changed lines 31-32 from:
to:
Changed line 37 from:
to:
January 22, 2010, at 12:04 AM by Tom Igoe -
Changed lines 31-120 from:
 #define NOTE_B0  31
 #define NOTE_C1  33
 #define NOTE_CS1 35
 #define NOTE_D1  37
 #define NOTE_DS1 39
 #define NOTE_E1  41
 #define NOTE_F1  44
 #define NOTE_FS1 46
 #define NOTE_G1  49
 #define NOTE_GS1 52
 #define NOTE_A1  55
 #define NOTE_AS1 58
 #define NOTE_B1  62
 #define NOTE_C2  65
 #define NOTE_CS2 69
 #define NOTE_D2  73
 #define NOTE_DS2 78
 #define NOTE_E2  82
 #define NOTE_F2  87
 #define NOTE_FS2 93
 #define NOTE_G2  98
 #define NOTE_GS2 104
 #define NOTE_A2  110
 #define NOTE_AS2 117
 #define NOTE_B2  123
 #define NOTE_C3  131
 #define NOTE_CS3 139
 #define NOTE_D3  147
 #define NOTE_DS3 156
 #define NOTE_E3  165
 #define NOTE_F3  175
 #define NOTE_FS3 185
 #define NOTE_G3  196
 #define NOTE_GS3 208
 #define NOTE_A3  220
 #define NOTE_AS3 233
 #define NOTE_B3  247
 #define NOTE_C4  262
 #define NOTE_CS4 277
 #define NOTE_D4  294
 #define NOTE_DS4 311
 #define NOTE_E4  330
 #define NOTE_F4  349
 #define NOTE_FS4 370
 #define NOTE_G4  392
 #define NOTE_GS4 415
 #define NOTE_A4  440
 #define NOTE_AS4 466
 #define NOTE_B4  494
 #define NOTE_C5  523
 #define NOTE_CS5 554
 #define NOTE_D5  587
 #define NOTE_DS5 622
 #define NOTE_E5  659
 #define NOTE_F5  698
 #define NOTE_FS5 740
 #define NOTE_G5  784
 #define NOTE_GS5 831
 #define NOTE_A5  880
 #define NOTE_AS5 932
 #define NOTE_B5  988
 #define NOTE_C6  1047
 #define NOTE_CS6 1109
 #define NOTE_D6  1175
 #define NOTE_DS6 1245
 #define NOTE_E6  1319
 #define NOTE_F6  1397
 #define NOTE_FS6 1480
 #define NOTE_G6  1568
 #define NOTE_GS6 1661
 #define NOTE_A6  1760
 #define NOTE_AS6 1865
 #define NOTE_B6  1976
 #define NOTE_C7  2093
 #define NOTE_CS7 2217
 #define NOTE_D7  2349
 #define NOTE_DS7 2489
 #define NOTE_E7  2637
 #define NOTE_F7  2794
 #define NOTE_FS7 2960
 #define NOTE_G7  3136
 #define NOTE_GS7 3322
 #define NOTE_A7  3520
 #define NOTE_AS7 3729
 #define NOTE_B7  3951
 #define NOTE_C8  4186
 #define NOTE_CS8 4435
 #define NOTE_D8  4699
 #define NOTE_DS8 4978
to:
Changed lines 37-67 from:
 #include "pitches.h"

 // notes in the melody:
 int melody[] = {
   NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};

 // note durations: 4 = quarter note, 8 = eighth note, etc.:
 int noteDurations[] = {
   4, 8, 8, 4,4,4,4,4 };

 void setup() {
   // iterate over the notes of the melody:
   for (int thisNote = 0; thisNote < 8; thisNote++) {

     // to calculate the note duration, take one second 
     // divided by the note type.
     //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
     int noteDuration = 1000/noteDurations[thisNote];
     tone(8, melody[thisNote],noteDuration);

     // to distinguish the notes, set a minimum time between them.
     // the note's duration + 30% seems to work well:
     int pauseBetweenNotes = noteDuration * 1.30;
     delay(pauseBetweenNotes);
   }
 }

 void loop() {
   // no need to repeat the melody.
 }
to:
January 21, 2010, at 08:00 PM by Tom Igoe -
Changed lines 3-4 from:

Debounce

to:

Play Melody using the tone() function

January 21, 2010, at 05:49 PM by Tom Igoe -
Changed lines 31-120 from:
 &hash;define NOTE_B0  31
 &hash;define NOTE_C1  33

&hash;define NOTE_CS1 35 &hash;define NOTE_D1 37 &hash;define NOTE_DS1 39 &hash;define NOTE_E1 41 &hash;define NOTE_F1 44 &hash;define NOTE_FS1 46 &hash;define NOTE_G1 49 &hash;define NOTE_GS1 52 &hash;define NOTE_A1 55 &hash;define NOTE_AS1 58 &hash;define NOTE_B1 62 &hash;define NOTE_C2 65 &hash;define NOTE_CS2 69 &hash;define NOTE_D2 73 &hash;define NOTE_DS2 78 &hash;define NOTE_E2 82 &hash;define NOTE_F2 87 &hash;define NOTE_FS2 93 &hash;define NOTE_G2 98 &hash;define NOTE_GS2 104 &hash;define NOTE_A2 110 &hash;define NOTE_AS2 117 &hash;define NOTE_B2 123 &hash;define NOTE_C3 131 &hash;define NOTE_CS3 139 &hash;define NOTE_D3 147 &hash;define NOTE_DS3 156 &hash;define NOTE_E3 165 &hash;define NOTE_F3 175 &hash;define NOTE_FS3 185 &hash;define NOTE_G3 196 &hash;define NOTE_GS3 208 &hash;define NOTE_A3 220 &hash;define NOTE_AS3 233 &hash;define NOTE_B3 247 &hash;define NOTE_C4 262 &hash;define NOTE_CS4 277 &hash;define NOTE_D4 294 &hash;define NOTE_DS4 311 &hash;define NOTE_E4 330 &hash;define NOTE_F4 349 &hash;define NOTE_FS4 370 &hash;define NOTE_G4 392 &hash;define NOTE_GS4 415 &hash;define NOTE_A4 440 &hash;define NOTE_AS4 466 &hash;define NOTE_B4 494 &hash;define NOTE_C5 523 &hash;define NOTE_CS5 554 &hash;define NOTE_D5 587 &hash;define NOTE_DS5 622 &hash;define NOTE_E5 659 &hash;define NOTE_F5 698 &hash;define NOTE_FS5 740 &hash;define NOTE_G5 784 &hash;define NOTE_GS5 831 &hash;define NOTE_A5 880 &hash;define NOTE_AS5 932 &hash;define NOTE_B5 988 &hash;define NOTE_C6 1047 &hash;define NOTE_CS6 1109 &hash;define NOTE_D6 1175 &hash;define NOTE_DS6 1245 &hash;define NOTE_E6 1319 &hash;define NOTE_F6 1397 &hash;define NOTE_FS6 1480 &hash;define NOTE_G6 1568 &hash;define NOTE_GS6 1661 &hash;define NOTE_A6 1760 &hash;define NOTE_AS6 1865 &hash;define NOTE_B6 1976 &hash;define NOTE_C7 2093 &hash;define NOTE_CS7 2217 &hash;define NOTE_D7 2349 &hash;define NOTE_DS7 2489 &hash;define NOTE_E7 2637 &hash;define NOTE_F7 2794 &hash;define NOTE_FS7 2960 &hash;define NOTE_G7 3136 &hash;define NOTE_GS7 3322 &hash;define NOTE_A7 3520 &hash;define NOTE_AS7 3729 &hash;define NOTE_B7 3951 &hash;define NOTE_C8 4186 &hash;define NOTE_CS8 4435 &hash;define NOTE_D8 4699 &hash;define NOTE_DS8 4978

to:
 #define NOTE_B0  31
 #define NOTE_C1  33
 #define NOTE_CS1 35
 #define NOTE_D1  37
 #define NOTE_DS1 39
 #define NOTE_E1  41
 #define NOTE_F1  44
 #define NOTE_FS1 46
 #define NOTE_G1  49
 #define NOTE_GS1 52
 #define NOTE_A1  55
 #define NOTE_AS1 58
 #define NOTE_B1  62
 #define NOTE_C2  65
 #define NOTE_CS2 69
 #define NOTE_D2  73
 #define NOTE_DS2 78
 #define NOTE_E2  82
 #define NOTE_F2  87
 #define NOTE_FS2 93
 #define NOTE_G2  98
 #define NOTE_GS2 104
 #define NOTE_A2  110
 #define NOTE_AS2 117
 #define NOTE_B2  123
 #define NOTE_C3  131
 #define NOTE_CS3 139
 #define NOTE_D3  147
 #define NOTE_DS3 156
 #define NOTE_E3  165
 #define NOTE_F3  175
 #define NOTE_FS3 185
 #define NOTE_G3  196
 #define NOTE_GS3 208
 #define NOTE_A3  220
 #define NOTE_AS3 233
 #define NOTE_B3  247
 #define NOTE_C4  262
 #define NOTE_CS4 277
 #define NOTE_D4  294
 #define NOTE_DS4 311
 #define NOTE_E4  330
 #define NOTE_F4  349
 #define NOTE_FS4 370
 #define NOTE_G4  392
 #define NOTE_GS4 415
 #define NOTE_A4  440
 #define NOTE_AS4 466
 #define NOTE_B4  494
 #define NOTE_C5  523
 #define NOTE_CS5 554
 #define NOTE_D5  587
 #define NOTE_DS5 622
 #define NOTE_E5  659
 #define NOTE_F5  698
 #define NOTE_FS5 740
 #define NOTE_G5  784
 #define NOTE_GS5 831
 #define NOTE_A5  880
 #define NOTE_AS5 932
 #define NOTE_B5  988
 #define NOTE_C6  1047
 #define NOTE_CS6 1109
 #define NOTE_D6  1175
 #define NOTE_DS6 1245
 #define NOTE_E6  1319
 #define NOTE_F6  1397
 #define NOTE_FS6 1480
 #define NOTE_G6  1568
 #define NOTE_GS6 1661
 #define NOTE_A6  1760
 #define NOTE_AS6 1865
 #define NOTE_B6  1976
 #define NOTE_C7  2093
 #define NOTE_CS7 2217
 #define NOTE_D7  2349
 #define NOTE_DS7 2489
 #define NOTE_E7  2637
 #define NOTE_F7  2794
 #define NOTE_FS7 2960
 #define NOTE_G7  3136
 #define NOTE_GS7 3322
 #define NOTE_A7  3520
 #define NOTE_AS7 3729
 #define NOTE_B7  3951
 #define NOTE_C8  4186
 #define NOTE_CS8 4435
 #define NOTE_D8  4699
 #define NOTE_DS8 4978
January 21, 2010, at 05:48 PM by Tom Igoe -
Changed lines 31-32 from:

&hash;define NOTE_B0 31 &hash;define NOTE_C1 33

to:
 &hash;define NOTE_B0  31
 &hash;define NOTE_C1  33
January 21, 2010, at 05:48 PM by Tom Igoe -
Changed lines 31-121 from:

<pre>

  1. define NOTE_B0 31
  2. define NOTE_C1 33
  3. define NOTE_CS1 35
  4. define NOTE_D1 37
  5. define NOTE_DS1 39
  6. define NOTE_E1 41
  7. define NOTE_F1 44
  8. define NOTE_FS1 46
  9. define NOTE_G1 49
  10. define NOTE_GS1 52
  11. define NOTE_A1 55
  12. define NOTE_AS1 58
  13. define NOTE_B1 62
  14. define NOTE_C2 65
  15. define NOTE_CS2 69
  16. define NOTE_D2 73
  17. define NOTE_DS2 78
  18. define NOTE_E2 82
  19. define NOTE_F2 87
  20. define NOTE_FS2 93
  21. define NOTE_G2 98
  22. define NOTE_GS2 104
  23. define NOTE_A2 110
  24. define NOTE_AS2 117
  25. define NOTE_B2 123
  26. define NOTE_C3 131
  27. define NOTE_CS3 139
  28. define NOTE_D3 147
  29. define NOTE_DS3 156
  30. define NOTE_E3 165
  31. define NOTE_F3 175
  32. define NOTE_FS3 185
  33. define NOTE_G3 196
  34. define NOTE_GS3 208
  35. define NOTE_A3 220
  36. define NOTE_AS3 233
  37. define NOTE_B3 247
  38. define NOTE_C4 262
  39. define NOTE_CS4 277
  40. define NOTE_D4 294
  41. define NOTE_DS4 311
  42. define NOTE_E4 330
  43. define NOTE_F4 349
  44. define NOTE_FS4 370
  45. define NOTE_G4 392
  46. define NOTE_GS4 415
  47. define NOTE_A4 440
  48. define NOTE_AS4 466
  49. define NOTE_B4 494
  50. define NOTE_C5 523
  51. define NOTE_CS5 554
  52. define NOTE_D5 587
  53. define NOTE_DS5 622
  54. define NOTE_E5 659
  55. define NOTE_F5 698
  56. define NOTE_FS5 740
  57. define NOTE_G5 784
  58. define NOTE_GS5 831
  59. define NOTE_A5 880
  60. define NOTE_AS5 932
  61. define NOTE_B5 988
  62. define NOTE_C6 1047
  63. define NOTE_CS6 1109
  64. define NOTE_D6 1175
  65. define NOTE_DS6 1245
  66. define NOTE_E6 1319
  67. define NOTE_F6 1397
  68. define NOTE_FS6 1480
  69. define NOTE_G6 1568
  70. define NOTE_GS6 1661
  71. define NOTE_A6 1760
  72. define NOTE_AS6 1865
  73. define NOTE_B6 1976
  74. define NOTE_C7 2093
  75. define NOTE_CS7 2217
  76. define NOTE_D7 2349
  77. define NOTE_DS7 2489
  78. define NOTE_E7 2637
  79. define NOTE_F7 2794
  80. define NOTE_FS7 2960
  81. define NOTE_G7 3136
  82. define NOTE_GS7 3322
  83. define NOTE_A7 3520
  84. define NOTE_AS7 3729
  85. define NOTE_B7 3951
  86. define NOTE_C8 4186
  87. define NOTE_CS8 4435
  88. define NOTE_D8 4699
  89. define NOTE_DS8 4978

</pre>

to:

&hash;define NOTE_B0 31 &hash;define NOTE_C1 33 &hash;define NOTE_CS1 35 &hash;define NOTE_D1 37 &hash;define NOTE_DS1 39 &hash;define NOTE_E1 41 &hash;define NOTE_F1 44 &hash;define NOTE_FS1 46 &hash;define NOTE_G1 49 &hash;define NOTE_GS1 52 &hash;define NOTE_A1 55 &hash;define NOTE_AS1 58 &hash;define NOTE_B1 62 &hash;define NOTE_C2 65 &hash;define NOTE_CS2 69 &hash;define NOTE_D2 73 &hash;define NOTE_DS2 78 &hash;define NOTE_E2 82 &hash;define NOTE_F2 87 &hash;define NOTE_FS2 93 &hash;define NOTE_G2 98 &hash;define NOTE_GS2 104 &hash;define NOTE_A2 110 &hash;define NOTE_AS2 117 &hash;define NOTE_B2 123 &hash;define NOTE_C3 131 &hash;define NOTE_CS3 139 &hash;define NOTE_D3 147 &hash;define NOTE_DS3 156 &hash;define NOTE_E3 165 &hash;define NOTE_F3 175 &hash;define NOTE_FS3 185 &hash;define NOTE_G3 196 &hash;define NOTE_GS3 208 &hash;define NOTE_A3 220 &hash;define NOTE_AS3 233 &hash;define NOTE_B3 247 &hash;define NOTE_C4 262 &hash;define NOTE_CS4 277 &hash;define NOTE_D4 294 &hash;define NOTE_DS4 311 &hash;define NOTE_E4 330 &hash;define NOTE_F4 349 &hash;define NOTE_FS4 370 &hash;define NOTE_G4 392 &hash;define NOTE_GS4 415 &hash;define NOTE_A4 440 &hash;define NOTE_AS4 466 &hash;define NOTE_B4 494 &hash;define NOTE_C5 523 &hash;define NOTE_CS5 554 &hash;define NOTE_D5 587 &hash;define NOTE_DS5 622 &hash;define NOTE_E5 659 &hash;define NOTE_F5 698 &hash;define NOTE_FS5 740 &hash;define NOTE_G5 784 &hash;define NOTE_GS5 831 &hash;define NOTE_A5 880 &hash;define NOTE_AS5 932 &hash;define NOTE_B5 988 &hash;define NOTE_C6 1047 &hash;define NOTE_CS6 1109 &hash;define NOTE_D6 1175 &hash;define NOTE_DS6 1245 &hash;define NOTE_E6 1319 &hash;define NOTE_F6 1397 &hash;define NOTE_FS6 1480 &hash;define NOTE_G6 1568 &hash;define NOTE_GS6 1661 &hash;define NOTE_A6 1760 &hash;define NOTE_AS6 1865 &hash;define NOTE_B6 1976 &hash;define NOTE_C7 2093 &hash;define NOTE_CS7 2217 &hash;define NOTE_D7 2349 &hash;define NOTE_DS7 2489 &hash;define NOTE_E7 2637 &hash;define NOTE_F7 2794 &hash;define NOTE_FS7 2960 &hash;define NOTE_G7 3136 &hash;define NOTE_GS7 3322 &hash;define NOTE_A7 3520 &hash;define NOTE_AS7 3729 &hash;define NOTE_B7 3951 &hash;define NOTE_C8 4186 &hash;define NOTE_CS8 4435 &hash;define NOTE_D8 4699 &hash;define NOTE_DS8 4978

January 21, 2010, at 05:47 PM by Tom Igoe -
Changed line 31 from:
to:

<pre>

Added line 121:

</pre>

January 21, 2010, at 05:44 PM by Tom Igoe -
Changed lines 9-10 from:
to:
Changed lines 18-20 from:

to:

January 21, 2010, at 05:42 PM by Tom Igoe -
Changed lines 9-10 from:
to:
Changed lines 18-20 from:

to:

January 21, 2010, at 05:40 PM by Tom Igoe -
Added lines 1-156:

Share