For Ryan...

posted Dec 17, 2009, 8:38 AM by Unknown user
Okay, so since we're apparently the "Music Girls" and a certain SOMEONE keeps coming back to us with questions, we decided to make a post just for making music with Arduino. It's a basic post, we're not going to go into detail how you use Tone Library. We're assuming you have installed it and basically know how it works. Remember, CASE IS IMPORTANT.

Put this where you put all your other variables:
#include <Tone.h>                
  Tone noiseMaker;

Put this in void setup:
noiseMaker.begin(2)   <---- 2 is the pin that your speaker is plugged into. (The other is plugged into ground)

Now, to PLAY the note:
noiseMaker.play(NOTE_C2)

OR

noiseMaker.play(65.41) <---- this is the same note. It's just the frequency of the note. This is a better way to put it if you are going to change it in the sketch. (Like we did with                   
                                            the aluminum foil version of the piano gloves [see 12/17/09]) Frequency Chart: http://www.phy.mtu.edu/~suits/notefreqs.html

So that's basically it. Come see us if you have anymore questions.



Comments