school assignment involving audio and buttons.

I'm doing an arduino project in school and I was going to do a complement and insult button so one complemented and one insulted. the problem is that this is my first time actually using arduino so I don't know how to go about the code.

thanks, but where in the code would I do that? as I said I'm just starting arduino.

If it's going to "talk" you'll need some kind of [u]Audio Shield[/u] (add-on board) because the Arduino does not have a digital-to-analog converter.*

The audio shield has the DAC, a slot for a memory card to hold the audio file(s), the sample rate clock, sometimes an MP3 decoder, and everything else required to play audio. The Arduino just acts as a controller to start/stop the audio, etc.

Then depending on the audio shield, you may need an amplifier or amplified computer speakers.

The [u]Button Example[/u] shows how to wire-up and read a pushbutton switch, and turn-on an LED. (There is actually an easier way to wire buttons enabling the [u]built-in pull-up resistors[/u] instead of the user-supplied pull-down used in the example.)

Of course, you don't need a microcontroller & software to turn-on an LED with a switch/button, but it's a demonstration of how to read a button and then use an [u]if-statement[/u] to turn-on the LED.

If-statements (and a couple of other similar instructions) are the way that computers "make" decisions". This kind of "conditional execution" along with loops (doing something over-and-over, usually until some condition is reached) are the two most important concepts in programming, and once you understand those concepts you can start to write useful programs. (Of course, there's a LOT more to programming.)

And, I'd recommend you "develop" your project a little at a time, maybe starting with red & green LEDs instead of audio. Once the main logic is working you can start on the audio.

  • There is a library called TMRpcm that uses PWM to "simulate" analog audio but it can cause "complications" and I'd recommend against it.