Lab: Tone Output

It took me a bit to get the speaker making sound in this lab. One of my issues was that I did not have the correct pin set as the first parameter to the tone function. I had copied to code from the lab site without understanding the function parameters to tone. I now know that the parameters are tone(pin, frequency, duration) where duration is optional. Also the speaker does not sound without having the delay(duration) line of code uploaded to the aurdino.

Q: I am generally confused as to when pinMode is necessary. In this lab we have set up a variable resistor to A0 but do not need to set it as an input pin. Seems like pinMode is only needed for digital input and output. pinMode not necessary when using tone() function maybe because you explicitly specify the pin number here.

Jumpy Current x Sound

Screen Shot 2021-09-26 at 9.01.10 PM.png

What a alternation between 0 500 and 10000 sounds like through a speaker. Wired my board wrong to come up with this sound. Sounds like a video game!

What a alternation between 0 500 and 10000 sounds like through a speaker. Wired my board wrong to come up with this sound. Sounds like a video game!

I got the speaker tested and working, but having trouble getting my variable resister working. I am getting 0-15 reads on the sensor. I have tried both a photocell and variable transistor with no luck getting this working.

Why is this set up not working? A0 is being read at 0-15 ? Going to try restarting IDE next and play around measuring voltage.

Why is this set up not working? A0 is being read at 0-15 ? Going to try restarting IDE next and play around measuring voltage.

Returning to this issue documented above. I tried closing and reopening the IDE with no luck. Next I got out a multimeter and found that the 5V power supply on my Arduino was producing no power! I moved my red wire to attach to the 3.3 v pin and started getting readings for my photocell in the Serial Monitor.

Creating and Playing a Melody using an Arduino

Set up of my instrument went smoothly. I learned that you can abbreviate A0-A4 to 0-4 in analogRead function which is helpful when using them in a loop.

melody.mov

A Musical Instrument