How do I play a singe tone?

I just need to play a single tone with this little speaker for two seconds, but the only example of how to program for it is the "melody" example which does much more than I need.

I don't know how to separate out code from that example for a single note

I only want to play a single tone. What is the grammar format for a single tone?

Note: E2


Simple crude way: Connect to a PWM output pin, such as 3.
analogWrite (3, 128);
delay (2000);
analogWrite (3, 0);

Use a 1 uF capacitor between the arduino output pin and this:

connect the 1000 ohm side to the capacitor and the 8 ohm side to the speaker.

Ok, so it's just like an LED, you give a # pin a # power level and it plays a tone.


The reference page for tone() Arduino - Tone tells you all you need to know

tone(pin, frequency, duration)

pin: the pin on which to generate the tone
frequency: the frequency of the tone in hertz - unsigned int
duration: the duration of the tone in milliseconds (optional) - unsigned long