Any musician-programmers in the house? I need help with choosing tones. I have been following the SparkFun beginner tutorials. I’m as far as sounding a buzzer. The circuit is simple. Find a little Piezo device and plug the black wire into the Arduino board’s ground pin hole. Plug the red wire into pin 8. Upload the sketch and it plays. Great! But not a catchy tune, imho. So, I decided to try a tune I know. That’s where I got into trouble. Luckily, the SparkFun sketch includes a link to an Arduino tutorial, which includes a helpful library (link below). Without that library picking notes is guesswork. It was also my first attempt at copying library code to a new tab, naming and saving the file (pitches.h). For my first number, I will play Twinkle Twinkle Little Star. This is the code I am using:
// notes in the melody:
int melody[] = {
NOTE_G4, NOTE_G4, NOTE_B4, NOTE_B4, NOTE_C5, NOTE_C5, NOTE_G4
};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
4, 4, 4, 4, 4, 4, 2
};
I seem to have the count, but the tones don’t sound right to my ears. Can any musician-programmers suggest better code notes? I would like to write the whole piece. See attached original score. Thanks!