Skip to content

Commit 5d5f1af

Browse files
authored
Update toneMelody.ino
1 parent eb709fa commit 5d5f1af

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/02.Digital/toneMelody/toneMelody.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "pitches.h"
1919

20+
int buzzerPin = 8;
21+
2022
// notes in the melody:
2123
int melody[] = {
2224
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
@@ -34,14 +36,14 @@ void setup() {
3436
// to calculate the note duration, take one second divided by the note type.
3537
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
3638
int noteDuration = 1000 / noteDurations[thisNote];
37-
tone(8, melody[thisNote], noteDuration);
39+
tone(buzzerPin, melody[thisNote], noteDuration);
3840

3941
// to distinguish the notes, set a minimum time between them.
4042
// the note's duration + 30% seems to work well:
4143
int pauseBetweenNotes = noteDuration * 1.30;
4244
delay(pauseBetweenNotes);
4345
// stop the tone playing:
44-
noTone(8);
46+
noTone(buzzerPin);
4547
}
4648
}
4749

0 commit comments

Comments
 (0)