Mooguino

A place to hang out and chat with other like minded tinkerers

Moderators: phalanx, TS-Tim

Post Reply
brianuno
Posts: 37
Joined: Tue Jan 24, 2017 2:52 pm

Mooguino

Post by brianuno » Thu Mar 16, 2017 3:22 pm

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:

Code: Select all

// 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!

https://www.arduino.cc/en/Tutorial/Tone ... m=Tutorial
Attachments
TwinkleTwinkle.jpg

n1ist
Support Volunteer
Posts: 1006
Joined: Wed Mar 22, 2006 11:02 am

Re: Mooguino

Post by n1ist » Thu Mar 16, 2017 9:01 pm

The code doesn't match the score...
Try NOTE_G4, NOTE_G4, NOTE_D5, NOTE_D5, NOTE_E5, NOTE_E5, NOTE_D5
http://notebusters.net/wp-content/uploa ... rkbook.png
Though most versions I see on Google are
NOTE_C4, NOTE_C4, NOTE_G4, NOTE_G4, NOTE_A5, NOTE_A5, NOTE_G4
(I haven't played an instrument in years, so this is from long-forgotten memories...)

brianuno
Posts: 37
Joined: Tue Jan 24, 2017 2:52 pm

Re: Mooguino

Post by brianuno » Fri Mar 17, 2017 12:13 pm

Thank you. I mean that because writing code, compared to cut-and-paste, is trying. I like your transcription of the notes better than the alternative provided. That pitch change to NOTE_A5, can't be intentional. I mean, try singing that. My friends would look at me.

Post Reply